OLD | NEW |
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 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 | 53 |
54 class MediaStreamTest: public testing::Test { | 54 class MediaStreamTest: public testing::Test { |
55 protected: | 55 protected: |
56 virtual void SetUp() { | 56 virtual void SetUp() { |
57 stream_ = MediaStream::Create(kStreamLabel1); | 57 stream_ = MediaStream::Create(kStreamLabel1); |
58 ASSERT_TRUE(stream_.get() != NULL); | 58 ASSERT_TRUE(stream_.get() != NULL); |
59 | 59 |
60 video_track_ = | 60 video_track_ = |
61 VideoTrack::Create(kVideoTrackId, FakeVideoTrackSource::Create()); | 61 VideoTrack::Create(kVideoTrackId, FakeVideoTrackSource::Create()); |
62 ASSERT_TRUE(video_track_.get() != NULL); | 62 ASSERT_TRUE(video_track_.get() != NULL); |
63 EXPECT_EQ(MediaStreamTrackInterface::kInitializing, video_track_->state()); | 63 EXPECT_EQ(MediaStreamTrackInterface::kLive, video_track_->state()); |
64 | 64 |
65 audio_track_ = AudioTrack::Create(kAudioTrackId, NULL); | 65 audio_track_ = AudioTrack::Create(kAudioTrackId, NULL); |
66 | 66 |
67 ASSERT_TRUE(audio_track_.get() != NULL); | 67 ASSERT_TRUE(audio_track_.get() != NULL); |
68 EXPECT_EQ(MediaStreamTrackInterface::kInitializing, audio_track_->state()); | 68 EXPECT_EQ(MediaStreamTrackInterface::kLive, audio_track_->state()); |
69 | 69 |
70 EXPECT_TRUE(stream_->AddTrack(video_track_)); | 70 EXPECT_TRUE(stream_->AddTrack(video_track_)); |
71 EXPECT_FALSE(stream_->AddTrack(video_track_)); | 71 EXPECT_FALSE(stream_->AddTrack(video_track_)); |
72 EXPECT_TRUE(stream_->AddTrack(audio_track_)); | 72 EXPECT_TRUE(stream_->AddTrack(audio_track_)); |
73 EXPECT_FALSE(stream_->AddTrack(audio_track_)); | 73 EXPECT_FALSE(stream_->AddTrack(audio_track_)); |
74 } | 74 } |
75 | 75 |
76 void ChangeTrack(MediaStreamTrackInterface* track) { | 76 void ChangeTrack(MediaStreamTrackInterface* track) { |
77 MockObserver observer(track); | 77 MockObserver observer(track); |
78 | 78 |
79 EXPECT_CALL(observer, OnChanged()) | 79 EXPECT_CALL(observer, OnChanged()) |
80 .Times(Exactly(1)); | 80 .Times(Exactly(1)); |
81 track->set_enabled(false); | 81 track->set_enabled(false); |
82 EXPECT_FALSE(track->enabled()); | 82 EXPECT_FALSE(track->enabled()); |
83 | 83 |
84 EXPECT_CALL(observer, OnChanged()) | 84 EXPECT_CALL(observer, OnChanged()) |
85 .Times(Exactly(1)); | 85 .Times(Exactly(1)); |
86 track->set_state(MediaStreamTrackInterface::kLive); | 86 track->set_state(MediaStreamTrackInterface::kEnded); |
87 EXPECT_EQ(MediaStreamTrackInterface::kLive, track->state()); | 87 EXPECT_EQ(MediaStreamTrackInterface::kEnded, track->state()); |
88 } | 88 } |
89 | 89 |
90 scoped_refptr<MediaStreamInterface> stream_; | 90 scoped_refptr<MediaStreamInterface> stream_; |
91 scoped_refptr<AudioTrackInterface> audio_track_; | 91 scoped_refptr<AudioTrackInterface> audio_track_; |
92 scoped_refptr<VideoTrackInterface> video_track_; | 92 scoped_refptr<VideoTrackInterface> video_track_; |
93 }; | 93 }; |
94 | 94 |
95 TEST_F(MediaStreamTest, GetTrackInfo) { | 95 TEST_F(MediaStreamTest, GetTrackInfo) { |
96 ASSERT_EQ(1u, stream_->GetVideoTracks().size()); | 96 ASSERT_EQ(1u, stream_->GetVideoTracks().size()); |
97 ASSERT_EQ(1u, stream_->GetAudioTracks().size()); | 97 ASSERT_EQ(1u, stream_->GetAudioTracks().size()); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 ChangeTrack(video_track.get()); | 151 ChangeTrack(video_track.get()); |
152 } | 152 } |
153 | 153 |
154 TEST_F(MediaStreamTest, ChangeAudioTrack) { | 154 TEST_F(MediaStreamTest, ChangeAudioTrack) { |
155 scoped_refptr<webrtc::AudioTrackInterface> audio_track( | 155 scoped_refptr<webrtc::AudioTrackInterface> audio_track( |
156 stream_->GetAudioTracks()[0]); | 156 stream_->GetAudioTracks()[0]); |
157 ChangeTrack(audio_track.get()); | 157 ChangeTrack(audio_track.get()); |
158 } | 158 } |
159 | 159 |
160 } // namespace webrtc | 160 } // namespace webrtc |
OLD | NEW |