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

Side by Side Diff: mojo/services/view_manager/view_manager_unittest.cc

Issue 380413003: Mojo: Use InterfaceFactory<Interface> for service registration (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix network_service_loader Created 6 years, 5 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <string> 5 #include <string>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/at_exit.h" 8 #include "base/at_exit.h"
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 300
301 // static 301 // static
302 base::RunLoop* ViewManagerProxy::main_run_loop_ = NULL; 302 base::RunLoop* ViewManagerProxy::main_run_loop_ = NULL;
303 303
304 // static 304 // static
305 bool ViewManagerProxy::in_embed_ = false; 305 bool ViewManagerProxy::in_embed_ = false;
306 306
307 class TestViewManagerClientConnection 307 class TestViewManagerClientConnection
308 : public InterfaceImpl<ViewManagerClient> { 308 : public InterfaceImpl<ViewManagerClient> {
309 public: 309 public:
310 TestViewManagerClientConnection(ApplicationConnection* app_connection) : 310 explicit TestViewManagerClientConnection() : connection_(&tracker_) {
311 connection_(&tracker_) {
312 tracker_.set_delegate(&connection_); 311 tracker_.set_delegate(&connection_);
313 } 312 }
314 313
315 // InterfaceImp: 314 // InterfaceImp:
316 virtual void OnConnectionEstablished() OVERRIDE { 315 virtual void OnConnectionEstablished() OVERRIDE {
317 connection_.set_router(internal_state()->router()); 316 connection_.set_router(internal_state()->router());
318 connection_.set_view_manager(client()); 317 connection_.set_view_manager(client());
319 } 318 }
320 319
321 // ViewManagerClient: 320 // ViewManagerClient:
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 371
373 private: 372 private:
374 TestChangeTracker tracker_; 373 TestChangeTracker tracker_;
375 ViewManagerProxy connection_; 374 ViewManagerProxy connection_;
376 375
377 DISALLOW_COPY_AND_ASSIGN(TestViewManagerClientConnection); 376 DISALLOW_COPY_AND_ASSIGN(TestViewManagerClientConnection);
378 }; 377 };
379 378
380 // Used with ViewManagerService::Embed(). Creates a 379 // Used with ViewManagerService::Embed(). Creates a
381 // TestViewManagerClientConnection, which creates and owns the ViewManagerProxy. 380 // TestViewManagerClientConnection, which creates and owns the ViewManagerProxy.
382 class EmbedServiceLoader : public ServiceLoader, ApplicationDelegate { 381 class EmbedServiceLoader : public ServiceLoader,
382 ApplicationDelegate,
383 public InterfaceFactory<ViewManagerClient> {
383 public: 384 public:
384 EmbedServiceLoader() {} 385 EmbedServiceLoader() {}
385 virtual ~EmbedServiceLoader() {} 386 virtual ~EmbedServiceLoader() {}
386 387
387 // ServiceLoader: 388 // ServiceLoader implementation:
388 virtual void LoadService(ServiceManager* manager, 389 virtual void LoadService(ServiceManager* manager,
389 const GURL& url, 390 const GURL& url,
390 ScopedMessagePipeHandle shell_handle) OVERRIDE { 391 ScopedMessagePipeHandle shell_handle) OVERRIDE {
391 scoped_ptr<ApplicationImpl> app(new ApplicationImpl(this, 392 scoped_ptr<ApplicationImpl> app(new ApplicationImpl(this,
392 shell_handle.Pass())); 393 shell_handle.Pass()));
393 apps_.push_back(app.release()); 394 apps_.push_back(app.release());
394 } 395 }
395 virtual void OnServiceError(ServiceManager* manager, 396 virtual void OnServiceError(ServiceManager* manager,
396 const GURL& url) OVERRIDE { 397 const GURL& url) OVERRIDE {
397 } 398 }
398 399
399 // ApplicationDelegate 400 // ApplicationDelegate implementation:
400 virtual bool ConfigureIncomingConnection(ApplicationConnection* connection) 401 virtual bool ConfigureIncomingConnection(ApplicationConnection* connection)
401 OVERRIDE { 402 OVERRIDE {
402 connection->AddService<TestViewManagerClientConnection>(); 403 connection->AddService(this);
403 return true; 404 return true;
404 } 405 }
405 406
407 // InterfaceFactory<ViewManagerClient> implementation:
408 virtual void Create(ApplicationConnection* connection,
409 InterfaceRequest<ViewManagerClient> request) OVERRIDE {
410 BindToRequest(new TestViewManagerClientConnection, &request);
411 }
412
406 private: 413 private:
407 ScopedVector<ApplicationImpl> apps_; 414 ScopedVector<ApplicationImpl> apps_;
408 415
409 DISALLOW_COPY_AND_ASSIGN(EmbedServiceLoader); 416 DISALLOW_COPY_AND_ASSIGN(EmbedServiceLoader);
410 }; 417 };
411 418
412 // Creates an id used for transport from the specified parameters. 419 // Creates an id used for transport from the specified parameters.
413 Id BuildNodeId(ConnectionSpecificId connection_id, 420 Id BuildNodeId(ConnectionSpecificId connection_id,
414 ConnectionSpecificId node_id) { 421 ConnectionSpecificId node_id) {
415 return (connection_id << 16) | node_id; 422 return (connection_id << 16) | node_id;
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 ChangeNodeDescription(changes)); 510 ChangeNodeDescription(changes));
504 } 511 }
505 } 512 }
506 513
507 void DestroySecondConnection() { 514 void DestroySecondConnection() {
508 connection2_->Destroy(); 515 connection2_->Destroy();
509 connection2_ = NULL; 516 connection2_ = NULL;
510 } 517 }
511 518
512 base::ShadowingAtExitManager at_exit_; 519 base::ShadowingAtExitManager at_exit_;
520 shell::ShellTestHelper test_helper_;
513 base::MessageLoop loop_; 521 base::MessageLoop loop_;
514 shell::ShellTestHelper test_helper_;
515 522
516 ViewManagerInitServicePtr view_manager_init_; 523 ViewManagerInitServicePtr view_manager_init_;
517 524
518 ViewManagerProxy* connection_; 525 ViewManagerProxy* connection_;
519 ViewManagerProxy* connection2_; 526 ViewManagerProxy* connection2_;
520 527
521 DISALLOW_COPY_AND_ASSIGN(ViewManagerTest); 528 DISALLOW_COPY_AND_ASSIGN(ViewManagerTest);
522 }; 529 };
523 530
524 TEST_F(ViewManagerTest, SecondEmbedRoot_InitService) { 531 TEST_F(ViewManagerTest, SecondEmbedRoot_InitService) {
(...skipping 883 matching lines...) Expand 10 before | Expand all | Expand 10 after
1408 // originating connection. 1415 // originating connection.
1409 1416
1410 // TODO(beng): Add tests for focus: 1417 // TODO(beng): Add tests for focus:
1411 // - focus between two nodes known to a connection 1418 // - focus between two nodes known to a connection
1412 // - focus between nodes unknown to one of the connections. 1419 // - focus between nodes unknown to one of the connections.
1413 // - focus between nodes unknown to either connection. 1420 // - focus between nodes unknown to either connection.
1414 1421
1415 } // namespace service 1422 } // namespace service
1416 } // namespace view_manager 1423 } // namespace view_manager
1417 } // namespace mojo 1424 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/services/view_manager/root_node_manager.cc ('k') | mojo/services/window_manager/window_manager_api_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698