Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(283)

Unified Diff: talk/app/webrtc/mediastream_unittest.cc

Issue 1522903002: Add a 'remote' property to MediaSourceInterface. Also adding an implementation to the relevant sour… (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Address comments Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « talk/app/webrtc/localaudiosource.h ('k') | talk/app/webrtc/mediastreaminterface.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: talk/app/webrtc/mediastream_unittest.cc
diff --git a/talk/app/webrtc/mediastream_unittest.cc b/talk/app/webrtc/mediastream_unittest.cc
index 2cf930c4c0303821c714f8e9b0e61323e5e589e1..f19b9456a64db73f1cf76a5f0cfe1094bc5ea592 100644
--- a/talk/app/webrtc/mediastream_unittest.cc
+++ b/talk/app/webrtc/mediastream_unittest.cc
@@ -48,9 +48,23 @@ namespace webrtc {
// Helper class to test Observer.
class MockObserver : public ObserverInterface {
public:
- MockObserver() {}
+ explicit MockObserver(NotifierInterface* notifier) : notifier_(notifier) {
+ notifier_->RegisterObserver(this);
+ }
+
+ ~MockObserver() { Unregister(); }
+
+ void Unregister() {
+ if (notifier_) {
+ notifier_->UnregisterObserver(this);
+ notifier_ = nullptr;
+ }
+ }
MOCK_METHOD0(OnChanged, void());
+
+ private:
+ NotifierInterface* notifier_;
};
class MediaStreamTest: public testing::Test {
@@ -75,8 +89,7 @@ class MediaStreamTest: public testing::Test {
}
void ChangeTrack(MediaStreamTrackInterface* track) {
- MockObserver observer;
- track->RegisterObserver(&observer);
+ MockObserver observer(track);
EXPECT_CALL(observer, OnChanged())
.Times(Exactly(1));
@@ -127,8 +140,7 @@ TEST_F(MediaStreamTest, GetTrackInfo) {
}
TEST_F(MediaStreamTest, RemoveTrack) {
- MockObserver observer;
- stream_->RegisterObserver(&observer);
+ MockObserver observer(stream_);
EXPECT_CALL(observer, OnChanged())
.Times(Exactly(2));
« no previous file with comments | « talk/app/webrtc/localaudiosource.h ('k') | talk/app/webrtc/mediastreaminterface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698