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

Side by Side Diff: webrtc/api/mediastream_unittest.cc

Issue 1766653002: Replace SetCapturer and SetCaptureDevice by SetSource. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Work-in-progress, after applying 1790633002. Created 4 years, 9 months 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2011 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2011 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include <string> 11 #include <string>
12 12
13 #include "webrtc/api/audiotrack.h" 13 #include "webrtc/api/audiotrack.h"
14 #include "webrtc/api/mediastream.h" 14 #include "webrtc/api/mediastream.h"
15 #include "webrtc/api/videotrack.h" 15 #include "webrtc/api/videotrack.h"
16 #include "webrtc/api/test/fakevideotracksource.h"
16 #include "testing/gmock/include/gmock/gmock.h" 17 #include "testing/gmock/include/gmock/gmock.h"
17 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
18 #include "webrtc/base/gunit.h" 19 #include "webrtc/base/gunit.h"
19 #include "webrtc/base/refcount.h" 20 #include "webrtc/base/refcount.h"
20 #include "webrtc/base/scoped_ptr.h" 21 #include "webrtc/base/scoped_ptr.h"
21 22
22 static const char kStreamLabel1[] = "local_stream_1"; 23 static const char kStreamLabel1[] = "local_stream_1";
23 static const char kVideoTrackId[] = "dummy_video_cam_1"; 24 static const char kVideoTrackId[] = "dummy_video_cam_1";
24 static const char kAudioTrackId[] = "dummy_microphone_1"; 25 static const char kAudioTrackId[] = "dummy_microphone_1";
25 26
(...skipping 23 matching lines...) Expand all
49 private: 50 private:
50 NotifierInterface* notifier_; 51 NotifierInterface* notifier_;
51 }; 52 };
52 53
53 class MediaStreamTest: public testing::Test { 54 class MediaStreamTest: public testing::Test {
54 protected: 55 protected:
55 virtual void SetUp() { 56 virtual void SetUp() {
56 stream_ = MediaStream::Create(kStreamLabel1); 57 stream_ = MediaStream::Create(kStreamLabel1);
57 ASSERT_TRUE(stream_.get() != NULL); 58 ASSERT_TRUE(stream_.get() != NULL);
58 59
59 video_track_ = VideoTrack::Create(kVideoTrackId, NULL); 60 video_track_ =
61 VideoTrack::Create(kVideoTrackId, FakeVideoTrackSource::Create());
60 ASSERT_TRUE(video_track_.get() != NULL); 62 ASSERT_TRUE(video_track_.get() != NULL);
61 EXPECT_EQ(MediaStreamTrackInterface::kInitializing, video_track_->state()); 63 EXPECT_EQ(MediaStreamTrackInterface::kLive, video_track_->state());
62 64
63 audio_track_ = AudioTrack::Create(kAudioTrackId, NULL); 65 audio_track_ = AudioTrack::Create(kAudioTrackId, NULL);
64 66
65 ASSERT_TRUE(audio_track_.get() != NULL); 67 ASSERT_TRUE(audio_track_.get() != NULL);
66 EXPECT_EQ(MediaStreamTrackInterface::kInitializing, audio_track_->state()); 68 EXPECT_EQ(MediaStreamTrackInterface::kLive, audio_track_->state());
67 69
68 EXPECT_TRUE(stream_->AddTrack(video_track_)); 70 EXPECT_TRUE(stream_->AddTrack(video_track_));
69 EXPECT_FALSE(stream_->AddTrack(video_track_)); 71 EXPECT_FALSE(stream_->AddTrack(video_track_));
70 EXPECT_TRUE(stream_->AddTrack(audio_track_)); 72 EXPECT_TRUE(stream_->AddTrack(audio_track_));
71 EXPECT_FALSE(stream_->AddTrack(audio_track_)); 73 EXPECT_FALSE(stream_->AddTrack(audio_track_));
72 } 74 }
73 75
74 void ChangeTrack(MediaStreamTrackInterface* track) { 76 void ChangeTrack(MediaStreamTrackInterface* track) {
75 MockObserver observer(track); 77 MockObserver observer(track);
76 78
77 EXPECT_CALL(observer, OnChanged()) 79 EXPECT_CALL(observer, OnChanged())
78 .Times(Exactly(1)); 80 .Times(Exactly(1));
79 track->set_enabled(false); 81 track->set_enabled(false);
80 EXPECT_FALSE(track->enabled()); 82 EXPECT_FALSE(track->enabled());
81 83
84 EXPECT_EQ(MediaStreamTrackInterface::kLive, track->state());
82 EXPECT_CALL(observer, OnChanged()) 85 EXPECT_CALL(observer, OnChanged())
83 .Times(Exactly(1)); 86 .Times(Exactly(1));
84 track->set_state(MediaStreamTrackInterface::kLive); 87 track->set_state(MediaStreamTrackInterface::kEnded);
85 EXPECT_EQ(MediaStreamTrackInterface::kLive, track->state()); 88 EXPECT_EQ(MediaStreamTrackInterface::kEnded, track->state());
86 } 89 }
87 90
88 scoped_refptr<MediaStreamInterface> stream_; 91 scoped_refptr<MediaStreamInterface> stream_;
89 scoped_refptr<AudioTrackInterface> audio_track_; 92 scoped_refptr<AudioTrackInterface> audio_track_;
90 scoped_refptr<VideoTrackInterface> video_track_; 93 scoped_refptr<VideoTrackInterface> video_track_;
91 }; 94 };
92 95
93 TEST_F(MediaStreamTest, GetTrackInfo) { 96 TEST_F(MediaStreamTest, GetTrackInfo) {
94 ASSERT_EQ(1u, stream_->GetVideoTracks().size()); 97 ASSERT_EQ(1u, stream_->GetVideoTracks().size());
95 ASSERT_EQ(1u, stream_->GetAudioTracks().size()); 98 ASSERT_EQ(1u, stream_->GetAudioTracks().size());
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 ChangeTrack(video_track.get()); 152 ChangeTrack(video_track.get());
150 } 153 }
151 154
152 TEST_F(MediaStreamTest, ChangeAudioTrack) { 155 TEST_F(MediaStreamTest, ChangeAudioTrack) {
153 scoped_refptr<webrtc::AudioTrackInterface> audio_track( 156 scoped_refptr<webrtc::AudioTrackInterface> audio_track(
154 stream_->GetAudioTracks()[0]); 157 stream_->GetAudioTracks()[0]);
155 ChangeTrack(audio_track.get()); 158 ChangeTrack(audio_track.get());
156 } 159 }
157 160
158 } // namespace webrtc 161 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698