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: mojo/services/view_manager/view_manager_unittest.cc

Issue 718473003: Add mojo::Binding<Interface> for more flexible pipe<->impl binding (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Rename Binding::router() -> Binding::internal_router() Created 6 years, 1 month 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 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 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 : public InterfaceImpl<ViewManagerClient> { 344 : public InterfaceImpl<ViewManagerClient> {
345 public: 345 public:
346 TestViewManagerClientConnection() : proxy_(&tracker_) { 346 TestViewManagerClientConnection() : proxy_(&tracker_) {
347 tracker_.set_delegate(&proxy_); 347 tracker_.set_delegate(&proxy_);
348 } 348 }
349 349
350 TestChangeTracker* tracker() { return &tracker_; } 350 TestChangeTracker* tracker() { return &tracker_; }
351 351
352 ViewManagerProxy* proxy() { return &proxy_; } 352 ViewManagerProxy* proxy() { return &proxy_; }
353 353
354 // InterfaceImpl: 354 void OnConnectionEstablished() {
355 void OnConnectionEstablished() override { 355 proxy_.set_router(internal_router());
356 proxy()->set_router(internal_state()->router()); 356 proxy_.set_view_manager(client());
357 proxy()->set_view_manager(client());
358 } 357 }
359 358
360 // ViewManagerClient: 359 // ViewManagerClient:
361 void OnEmbed(ConnectionSpecificId connection_id, 360 void OnEmbed(ConnectionSpecificId connection_id,
362 const String& creator_url, 361 const String& creator_url,
363 ViewDataPtr root, 362 ViewDataPtr root,
364 InterfaceRequest<ServiceProvider> services, 363 InterfaceRequest<ServiceProvider> services,
365 ScopedMessagePipeHandle window_manager_pipe) override { 364 ScopedMessagePipeHandle window_manager_pipe) override {
366 tracker()->OnEmbed(connection_id, creator_url, root.Pass()); 365 tracker()->OnEmbed(connection_id, creator_url, root.Pass());
367 } 366 }
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 435
437 // ApplicationDelegate implementation: 436 // ApplicationDelegate implementation:
438 bool ConfigureIncomingConnection(ApplicationConnection* connection) override { 437 bool ConfigureIncomingConnection(ApplicationConnection* connection) override {
439 connection->AddService<ViewManagerClient>(this); 438 connection->AddService<ViewManagerClient>(this);
440 return true; 439 return true;
441 } 440 }
442 441
443 // InterfaceFactory<ViewManagerClient> implementation: 442 // InterfaceFactory<ViewManagerClient> implementation:
444 void Create(ApplicationConnection* connection, 443 void Create(ApplicationConnection* connection,
445 InterfaceRequest<ViewManagerClient> request) override { 444 InterfaceRequest<ViewManagerClient> request) override {
446 BindToRequest(new TestViewManagerClientConnection(), &request); 445 auto client_connection = new TestViewManagerClientConnection;
446 BindToRequest(client_connection, &request);
447 client_connection->OnConnectionEstablished();
447 } 448 }
448 449
449 private: 450 private:
450 ScopedVector<ApplicationImpl> apps_; 451 ScopedVector<ApplicationImpl> apps_;
451 452
452 DISALLOW_COPY_AND_ASSIGN(EmbedApplicationLoader); 453 DISALLOW_COPY_AND_ASSIGN(EmbedApplicationLoader);
453 }; 454 };
454 455
455 class TestWindowManagerImpl : public InterfaceImpl<WindowManager> { 456 class TestWindowManagerImpl : public InterfaceImpl<WindowManager> {
456 public: 457 public:
(...skipping 11 matching lines...) Expand all
468 window_manager_client_.get()); 469 window_manager_client_.get());
469 view_manager_client_->proxy()->set_view_manager(view_manager_.get()); 470 view_manager_client_->proxy()->set_view_manager(view_manager_.get());
470 } 471 }
471 472
472 virtual ~TestWindowManagerImpl() {} 473 virtual ~TestWindowManagerImpl() {}
473 474
474 TestViewManagerClientConnection* view_manager_client() { 475 TestViewManagerClientConnection* view_manager_client() {
475 return view_manager_client_; 476 return view_manager_client_;
476 } 477 }
477 478
478 // InterfaceImpl:
479 virtual void OnConnectionEstablished() override {}
480
481 // WindowManager: 479 // WindowManager:
482 void Embed(const String& url, 480 void Embed(const String& url,
483 InterfaceRequest<ServiceProvider> service_provider) override { 481 InterfaceRequest<ServiceProvider> service_provider) override {
484 if (!got_initial_embed_) { 482 if (!got_initial_embed_) {
485 got_initial_embed_ = true; 483 got_initial_embed_ = true;
486 return; 484 return;
487 } 485 }
488 view_manager_client_->tracker()->DelegateEmbed(url); 486 view_manager_client_->tracker()->DelegateEmbed(url);
489 } 487 }
490 void SetCapture(Id view, const Callback<void(bool)>& callback) override { 488 void SetCapture(Id view, const Callback<void(bool)>& callback) override {
(...skipping 1111 matching lines...) Expand 10 before | Expand all | Expand 10 after
1602 EXPECT_EQ("PropertyChanged view=1,1 key=one value=NULL", 1600 EXPECT_EQ("PropertyChanged view=1,1 key=one value=NULL",
1603 ChangesToDescription1(connection2_->changes())[0]); 1601 ChangesToDescription1(connection2_->changes())[0]);
1604 } 1602 }
1605 } 1603 }
1606 1604
1607 // WARNING: this class is deprecated and will be replaced with 1605 // WARNING: this class is deprecated and will be replaced with
1608 // view_manager_server_apptest soonish. Add new tests there. 1606 // view_manager_server_apptest soonish. Add new tests there.
1609 1607
1610 } // namespace service 1608 } // namespace service
1611 } // namespace mojo 1609 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698