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

Side by Side Diff: media/remoting/remoting_controller_unittest.cc

Issue 2435423002: Add media remoting unittests to media_unittests. (Closed)
Patch Set: Addressed comments. Created 4 years, 2 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
« no previous file with comments | « media/remoting/BUILD.gn ('k') | media/test/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/remoting/remoting_controller.h" 5 #include "media/remoting/remoting_controller.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "media/base/audio_decoder_config.h" 10 #include "media/base/audio_decoder_config.h"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 std::move(request)); 96 std::move(request));
97 } 97 }
98 98
99 private: 99 private:
100 bool start_will_fail_; 100 bool start_will_fail_;
101 101
102 DISALLOW_COPY_AND_ASSIGN(FakeRemoterFactory); 102 DISALLOW_COPY_AND_ASSIGN(FakeRemoterFactory);
103 }; 103 };
104 104
105 std::unique_ptr<RemotingController> CreateRemotingController( 105 std::unique_ptr<RemotingController> CreateRemotingController(
106 mojom::RemoterFactory* remoter_factory) { 106 bool start_will_fail) {
107 mojom::RemotingSourcePtr remoting_source; 107 mojom::RemotingSourcePtr remoting_source;
108 mojom::RemotingSourceRequest remoting_source_request = 108 mojom::RemotingSourceRequest remoting_source_request =
109 mojo::GetProxy(&remoting_source); 109 mojo::GetProxy(&remoting_source);
110 mojom::RemoterPtr remoter; 110 mojom::RemoterPtr remoter;
111 std::unique_ptr<mojom::RemoterFactory> remoter_factory =
112 base::MakeUnique<FakeRemoterFactory>(start_will_fail);
111 remoter_factory->Create(std::move(remoting_source), mojo::GetProxy(&remoter)); 113 remoter_factory->Create(std::move(remoting_source), mojo::GetProxy(&remoter));
112 std::unique_ptr<RemotingController> remoting_controller = 114 std::unique_ptr<RemotingController> remoting_controller =
113 base::MakeUnique<RemotingController>(std::move(remoting_source_request), 115 base::MakeUnique<RemotingController>(std::move(remoting_source_request),
114 std::move(remoter)); 116 std::move(remoter));
115 return remoting_controller; 117 return remoting_controller;
116 } 118 }
117 119
118 } // namespace 120 } // namespace
119 121
120 class RemotingControllerTest : public ::testing::Test { 122 class RemotingControllerTest : public ::testing::Test {
121 public: 123 public:
122 RemotingControllerTest() 124 RemotingControllerTest()
123 : remoting_controller_( 125 : remoting_controller_(CreateRemotingController(false)),
124 CreateRemotingController(new FakeRemoterFactory(false))),
125 is_remoting_(false) { 126 is_remoting_(false) {
126 remoting_controller_->SetSwitchRendererCallback(base::Bind( 127 remoting_controller_->SetSwitchRendererCallback(base::Bind(
127 &RemotingControllerTest::ToggleRenderer, base::Unretained(this))); 128 &RemotingControllerTest::ToggleRenderer, base::Unretained(this)));
128 } 129 }
129 ~RemotingControllerTest() override {} 130 ~RemotingControllerTest() override {}
130 131
131 void TearDown() final { RunUntilIdle(); } 132 void TearDown() final { RunUntilIdle(); }
132 133
133 static void RunUntilIdle() { base::RunLoop().RunUntilIdle(); } 134 static void RunUntilIdle() { base::RunLoop().RunUntilIdle(); }
134 135
(...skipping 17 matching lines...) Expand all
152 remoting_controller_->OnMetadataChanged(defaultMetadata()); 153 remoting_controller_->OnMetadataChanged(defaultMetadata());
153 RunUntilIdle(); 154 RunUntilIdle();
154 EXPECT_TRUE(is_remoting_); 155 EXPECT_TRUE(is_remoting_);
155 remoting_controller_->OnExitedFullscreen(); 156 remoting_controller_->OnExitedFullscreen();
156 RunUntilIdle(); 157 RunUntilIdle();
157 EXPECT_FALSE(is_remoting_); 158 EXPECT_FALSE(is_remoting_);
158 } 159 }
159 160
160 TEST_F(RemotingControllerTest, StartFailed) { 161 TEST_F(RemotingControllerTest, StartFailed) {
161 EXPECT_FALSE(is_remoting_); 162 EXPECT_FALSE(is_remoting_);
162 remoting_controller_ = CreateRemotingController(new FakeRemoterFactory(true)); 163 remoting_controller_ = CreateRemotingController(true);
163 remoting_controller_->SetSwitchRendererCallback(base::Bind( 164 remoting_controller_->SetSwitchRendererCallback(base::Bind(
164 &RemotingControllerTest::ToggleRenderer, base::Unretained(this))); 165 &RemotingControllerTest::ToggleRenderer, base::Unretained(this)));
165 remoting_controller_->OnSinkAvailable(); 166 remoting_controller_->OnSinkAvailable();
166 remoting_controller_->OnEnteredFullscreen(); 167 remoting_controller_->OnEnteredFullscreen();
167 remoting_controller_->OnMetadataChanged(defaultMetadata()); 168 remoting_controller_->OnMetadataChanged(defaultMetadata());
168 RunUntilIdle(); 169 RunUntilIdle();
169 EXPECT_FALSE(is_remoting_); 170 EXPECT_FALSE(is_remoting_);
170 } 171 }
171 172
172 } // namespace media 173 } // namespace media
OLDNEW
« no previous file with comments | « media/remoting/BUILD.gn ('k') | media/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698