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

Side by Side Diff: chrome/browser/media/router/mojo/media_router_mojo_test.h

Issue 2837363002: [Media Router] Use DialMediaSinkService in MediaRouterMojoImpl (Closed)
Patch Set: resolve code review comments from Mark Created 3 years, 7 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 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #ifndef CHROME_BROWSER_MEDIA_ROUTER_MOJO_MEDIA_ROUTER_MOJO_TEST_H_ 5 #ifndef CHROME_BROWSER_MEDIA_ROUTER_MOJO_MEDIA_ROUTER_MOJO_TEST_H_
6 #define CHROME_BROWSER_MEDIA_ROUTER_MOJO_MEDIA_ROUTER_MOJO_TEST_H_ 6 #define CHROME_BROWSER_MEDIA_ROUTER_MOJO_MEDIA_ROUTER_MOJO_TEST_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/test/mock_callback.h"
12 #include "chrome/browser/media/router/mock_media_router.h" 13 #include "chrome/browser/media/router/mock_media_router.h"
13 #include "chrome/browser/media/router/mojo/media_router_mojo_impl.h" 14 #include "chrome/browser/media/router/mojo/media_router_mojo_impl.h"
14 #include "chrome/browser/media/router/test_helper.h" 15 #include "chrome/browser/media/router/test_helper.h"
15 #include "chrome/common/media_router/mojo/media_router.mojom.h" 16 #include "chrome/common/media_router/mojo/media_router.mojom.h"
16 #include "chrome/test/base/testing_profile.h" 17 #include "chrome/test/base/testing_profile.h"
17 #include "content/public/test/test_browser_thread_bundle.h" 18 #include "content/public/test/test_browser_thread_bundle.h"
18 #include "extensions/browser/event_page_tracker.h" 19 #include "extensions/browser/event_page_tracker.h"
19 #include "extensions/common/extension.h" 20 #include "extensions/common/extension.h"
20 #include "mojo/public/cpp/bindings/binding.h" 21 #include "mojo/public/cpp/bindings/binding.h"
21 #include "testing/gmock/include/gmock/gmock.h" 22 #include "testing/gmock/include/gmock/gmock.h"
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 class MockMediaRouteControllerObserver : public MediaRouteController::Observer { 151 class MockMediaRouteControllerObserver : public MediaRouteController::Observer {
151 public: 152 public:
152 MockMediaRouteControllerObserver( 153 MockMediaRouteControllerObserver(
153 scoped_refptr<MediaRouteController> controller); 154 scoped_refptr<MediaRouteController> controller);
154 ~MockMediaRouteControllerObserver() override; 155 ~MockMediaRouteControllerObserver() override;
155 156
156 MOCK_METHOD1(OnMediaStatusUpdated, void(const MediaStatus& status)); 157 MOCK_METHOD1(OnMediaStatusUpdated, void(const MediaStatus& status));
157 MOCK_METHOD0(OnControllerInvalidated, void()); 158 MOCK_METHOD0(OnControllerInvalidated, void());
158 }; 159 };
159 160
161 // Mockable class for awaiting RegisterMediaRouteProvider callbacks.
162 class RegisterMediaRouteProviderHandler {
163 public:
164 RegisterMediaRouteProviderHandler();
165 ~RegisterMediaRouteProviderHandler();
166
167 void Invoke(const std::string& instance_id,
168 mojom::MediaRouteProviderConfigPtr config) {
Kevin M 2017/05/03 21:07:28 This is to deal with move-only |config|, right? Ma
zhaobin 2017/05/04 23:52:36 Done.
169 InvokeRaw(instance_id, config.get());
170 }
171
172 MOCK_METHOD2(InvokeRaw,
173 void(const std::string& instance_id,
174 mojom::MediaRouteProviderConfig* config));
175 };
176
160 // Tests the API call flow between the MediaRouterMojoImpl and the Media Router 177 // Tests the API call flow between the MediaRouterMojoImpl and the Media Router
161 // Mojo service in both directions. 178 // Mojo service in both directions.
162 class MediaRouterMojoTest : public ::testing::Test { 179 class MediaRouterMojoTest : public ::testing::Test {
163 public: 180 public:
164 MediaRouterMojoTest(); 181 MediaRouterMojoTest();
165 ~MediaRouterMojoTest() override; 182 ~MediaRouterMojoTest() override;
166 183
167 protected: 184 protected:
168 void SetUp() override; 185 void SetUp() override;
169 void TearDown() override; 186 void TearDown() override;
170 187
171 void ProcessEventLoop(); 188 void ProcessEventLoop();
172 189
173 void ConnectProviderManagerService(); 190 void ConnectProviderManagerService();
174 191
175 const std::string& extension_id() const { return extension_->id(); } 192 const std::string& extension_id() const { return extension_->id(); }
176 193
177 MediaRouterMojoImpl* router() const { return mock_media_router_.get(); } 194 MediaRouterMojoImpl* router() const { return mock_media_router_.get(); }
178 195
179 // Mock objects. 196 // Mock objects.
180 MockMediaRouteProvider mock_media_route_provider_; 197 MockMediaRouteProvider mock_media_route_provider_;
181 testing::NiceMock<MockEventPageTracker> mock_event_page_tracker_; 198 testing::NiceMock<MockEventPageTracker> mock_event_page_tracker_;
182 199
183 // Mojo proxy object for |mock_media_router_| 200 // Mojo proxy object for |mock_media_router_|
184 media_router::mojom::MediaRouterPtr media_router_proxy_; 201 media_router::mojom::MediaRouterPtr media_router_proxy_;
185 202
203 RegisterMediaRouteProviderHandler provide_handler_;
204
186 private: 205 private:
187 content::TestBrowserThreadBundle test_thread_bundle_; 206 content::TestBrowserThreadBundle test_thread_bundle_;
188 scoped_refptr<extensions::Extension> extension_; 207 scoped_refptr<extensions::Extension> extension_;
208 std::unique_ptr<TestingProfile> profile_;
Kevin M 2017/05/03 21:07:28 Why is this a unique_ptr?
zhaobin 2017/05/04 23:52:36 Done.
189 std::unique_ptr<MediaRouterMojoImpl> mock_media_router_; 209 std::unique_ptr<MediaRouterMojoImpl> mock_media_router_;
Kevin M 2017/05/03 21:07:28 Ditto here
zhaobin 2017/05/04 23:52:36 It was uniqe_ptr before. Leave it as it it...
190 std::unique_ptr<mojo::Binding<mojom::MediaRouteProvider>> binding_; 210 std::unique_ptr<mojo::Binding<mojom::MediaRouteProvider>> binding_;
191 211
192 DISALLOW_COPY_AND_ASSIGN(MediaRouterMojoTest); 212 DISALLOW_COPY_AND_ASSIGN(MediaRouterMojoTest);
193 }; 213 };
194 214
195 } // namespace media_router 215 } // namespace media_router
196 216
197 #endif // CHROME_BROWSER_MEDIA_ROUTER_MOJO_MEDIA_ROUTER_MOJO_TEST_H_ 217 #endif // CHROME_BROWSER_MEDIA_ROUTER_MOJO_MEDIA_ROUTER_MOJO_TEST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698