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

Unified Diff: webrtc/api/mediastream_unittest.cc

Issue 2514883002: Create //webrtc/api:libjingle_peerconnection_api + refactorings. (Closed)
Patch Set: Rebase Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/api/mediastream.cc ('k') | webrtc/api/mediastreaminterface.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/api/mediastream_unittest.cc
diff --git a/webrtc/api/mediastream_unittest.cc b/webrtc/api/mediastream_unittest.cc
deleted file mode 100644
index 5df08ce9cc5ce9c8e67629855a40e6a3961c09b4..0000000000000000000000000000000000000000
--- a/webrtc/api/mediastream_unittest.cc
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * Copyright 2011 The WebRTC project authors. All Rights Reserved.
- *
- * Use of this source code is governed by a BSD-style license
- * that can be found in the LICENSE file in the root of the source
- * tree. An additional intellectual property rights grant can be found
- * in the file PATENTS. All contributing project authors may
- * be found in the AUTHORS file in the root of the source tree.
- */
-
-#include <string>
-
-#include "webrtc/api/audiotrack.h"
-#include "webrtc/api/mediastream.h"
-#include "webrtc/api/test/fakevideotracksource.h"
-#include "webrtc/api/videotrack.h"
-#include "webrtc/base/gunit.h"
-#include "webrtc/base/refcount.h"
-#include "webrtc/test/gmock.h"
-#include "webrtc/test/gtest.h"
-
-static const char kStreamLabel1[] = "local_stream_1";
-static const char kVideoTrackId[] = "dummy_video_cam_1";
-static const char kAudioTrackId[] = "dummy_microphone_1";
-
-using rtc::scoped_refptr;
-using ::testing::Exactly;
-
-namespace webrtc {
-
-// Helper class to test Observer.
-class MockObserver : public ObserverInterface {
- public:
- 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 {
- protected:
- virtual void SetUp() {
- stream_ = MediaStream::Create(kStreamLabel1);
- ASSERT_TRUE(stream_.get() != NULL);
-
- video_track_ =
- VideoTrack::Create(kVideoTrackId, FakeVideoTrackSource::Create());
- ASSERT_TRUE(video_track_.get() != NULL);
- EXPECT_EQ(MediaStreamTrackInterface::kLive, video_track_->state());
-
- audio_track_ = AudioTrack::Create(kAudioTrackId, NULL);
-
- ASSERT_TRUE(audio_track_.get() != NULL);
- EXPECT_EQ(MediaStreamTrackInterface::kLive, audio_track_->state());
-
- EXPECT_TRUE(stream_->AddTrack(video_track_));
- EXPECT_FALSE(stream_->AddTrack(video_track_));
- EXPECT_TRUE(stream_->AddTrack(audio_track_));
- EXPECT_FALSE(stream_->AddTrack(audio_track_));
- }
-
- void ChangeTrack(MediaStreamTrackInterface* track) {
- MockObserver observer(track);
-
- EXPECT_CALL(observer, OnChanged())
- .Times(Exactly(1));
- track->set_enabled(false);
- EXPECT_FALSE(track->enabled());
- }
-
- scoped_refptr<MediaStreamInterface> stream_;
- scoped_refptr<AudioTrackInterface> audio_track_;
- scoped_refptr<VideoTrackInterface> video_track_;
-};
-
-TEST_F(MediaStreamTest, GetTrackInfo) {
- ASSERT_EQ(1u, stream_->GetVideoTracks().size());
- ASSERT_EQ(1u, stream_->GetAudioTracks().size());
-
- // Verify the video track.
- scoped_refptr<webrtc::MediaStreamTrackInterface> video_track(
- stream_->GetVideoTracks()[0]);
- EXPECT_EQ(0, video_track->id().compare(kVideoTrackId));
- EXPECT_TRUE(video_track->enabled());
-
- ASSERT_EQ(1u, stream_->GetVideoTracks().size());
- EXPECT_TRUE(stream_->GetVideoTracks()[0].get() == video_track.get());
- EXPECT_TRUE(stream_->FindVideoTrack(video_track->id()).get()
- == video_track.get());
- video_track = stream_->GetVideoTracks()[0];
- EXPECT_EQ(0, video_track->id().compare(kVideoTrackId));
- EXPECT_TRUE(video_track->enabled());
-
- // Verify the audio track.
- scoped_refptr<webrtc::MediaStreamTrackInterface> audio_track(
- stream_->GetAudioTracks()[0]);
- EXPECT_EQ(0, audio_track->id().compare(kAudioTrackId));
- EXPECT_TRUE(audio_track->enabled());
- ASSERT_EQ(1u, stream_->GetAudioTracks().size());
- EXPECT_TRUE(stream_->GetAudioTracks()[0].get() == audio_track.get());
- EXPECT_TRUE(stream_->FindAudioTrack(audio_track->id()).get()
- == audio_track.get());
- audio_track = stream_->GetAudioTracks()[0];
- EXPECT_EQ(0, audio_track->id().compare(kAudioTrackId));
- EXPECT_TRUE(audio_track->enabled());
-}
-
-TEST_F(MediaStreamTest, RemoveTrack) {
- MockObserver observer(stream_);
-
- EXPECT_CALL(observer, OnChanged())
- .Times(Exactly(2));
-
- EXPECT_TRUE(stream_->RemoveTrack(audio_track_));
- EXPECT_FALSE(stream_->RemoveTrack(audio_track_));
- EXPECT_EQ(0u, stream_->GetAudioTracks().size());
- EXPECT_EQ(0u, stream_->GetAudioTracks().size());
-
- EXPECT_TRUE(stream_->RemoveTrack(video_track_));
- EXPECT_FALSE(stream_->RemoveTrack(video_track_));
-
- EXPECT_EQ(0u, stream_->GetVideoTracks().size());
- EXPECT_EQ(0u, stream_->GetVideoTracks().size());
-
- EXPECT_FALSE(stream_->RemoveTrack(static_cast<AudioTrackInterface*>(NULL)));
- EXPECT_FALSE(stream_->RemoveTrack(static_cast<VideoTrackInterface*>(NULL)));
-}
-
-TEST_F(MediaStreamTest, ChangeVideoTrack) {
- scoped_refptr<webrtc::VideoTrackInterface> video_track(
- stream_->GetVideoTracks()[0]);
- ChangeTrack(video_track.get());
-}
-
-TEST_F(MediaStreamTest, ChangeAudioTrack) {
- scoped_refptr<webrtc::AudioTrackInterface> audio_track(
- stream_->GetAudioTracks()[0]);
- ChangeTrack(audio_track.get());
-}
-
-} // namespace webrtc
« no previous file with comments | « webrtc/api/mediastream.cc ('k') | webrtc/api/mediastreaminterface.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698