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

Side by Side Diff: components/mus/ws/window_tree_apptest.cc

Issue 1675083002: Rename ApplicationDelegate to ShellClient (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@delegate
Patch Set: . Created 4 years, 10 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 | « components/mus/ws/window_manager_client_apptest.cc ('k') | components/pdf_viewer/pdf_viewer.cc » ('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 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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
11 #include "base/run_loop.h" 11 #include "base/run_loop.h"
12 #include "base/strings/stringprintf.h" 12 #include "base/strings/stringprintf.h"
13 #include "components/mus/public/interfaces/window_tree.mojom.h" 13 #include "components/mus/public/interfaces/window_tree.mojom.h"
14 #include "components/mus/public/interfaces/window_tree_host.mojom.h" 14 #include "components/mus/public/interfaces/window_tree_host.mojom.h"
15 #include "components/mus/ws/ids.h" 15 #include "components/mus/ws/ids.h"
16 #include "components/mus/ws/test_change_tracker.h" 16 #include "components/mus/ws/test_change_tracker.h"
17 #include "mojo/converters/geometry/geometry_type_converters.h" 17 #include "mojo/converters/geometry/geometry_type_converters.h"
18 #include "mojo/public/cpp/bindings/associated_binding.h" 18 #include "mojo/public/cpp/bindings/associated_binding.h"
19 #include "mojo/shell/public/cpp/application_delegate.h"
20 #include "mojo/shell/public/cpp/application_test_base.h" 19 #include "mojo/shell/public/cpp/application_test_base.h"
21 20
22 using mojo::ApplicationConnection;
23 using mojo::ApplicationDelegate;
24 using mojo::Array; 21 using mojo::Array;
25 using mojo::Callback; 22 using mojo::Callback;
23 using mojo::Connection;
26 using mojo::InterfaceRequest; 24 using mojo::InterfaceRequest;
27 using mojo::RectPtr; 25 using mojo::RectPtr;
26 using mojo::ShellClient;
28 using mojo::String; 27 using mojo::String;
29 using mus::mojom::ErrorCode; 28 using mus::mojom::ErrorCode;
30 using mus::mojom::EventPtr; 29 using mus::mojom::EventPtr;
31 using mus::mojom::ViewportMetricsPtr; 30 using mus::mojom::ViewportMetricsPtr;
32 using mus::mojom::WindowDataPtr; 31 using mus::mojom::WindowDataPtr;
33 using mus::mojom::WindowTree; 32 using mus::mojom::WindowTree;
34 using mus::mojom::WindowTreeClient; 33 using mus::mojom::WindowTreeClient;
35 34
36 namespace mus { 35 namespace mus {
37 namespace ws { 36 namespace ws {
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 DCHECK(!run_loop_); 441 DCHECK(!run_loop_);
443 run_loop_.reset(new base::RunLoop); 442 run_loop_.reset(new base::RunLoop);
444 run_loop_->Run(); 443 run_loop_->Run();
445 run_loop_.reset(); 444 run_loop_.reset();
446 } 445 }
447 return std::move(client_impl_); 446 return std::move(client_impl_);
448 } 447 }
449 448
450 private: 449 private:
451 // InterfaceFactory<WindowTreeClient>: 450 // InterfaceFactory<WindowTreeClient>:
452 void Create(ApplicationConnection* connection, 451 void Create(Connection* connection,
453 InterfaceRequest<WindowTreeClient> request) override { 452 InterfaceRequest<WindowTreeClient> request) override {
454 client_impl_.reset(new TestWindowTreeClientImpl()); 453 client_impl_.reset(new TestWindowTreeClientImpl());
455 client_impl_->Bind(std::move(request)); 454 client_impl_->Bind(std::move(request));
456 if (run_loop_.get()) 455 if (run_loop_.get())
457 run_loop_->Quit(); 456 run_loop_->Quit();
458 } 457 }
459 458
460 scoped_ptr<TestWindowTreeClientImpl> client_impl_; 459 scoped_ptr<TestWindowTreeClientImpl> client_impl_;
461 scoped_ptr<base::RunLoop> run_loop_; 460 scoped_ptr<base::RunLoop> run_loop_;
462 461
463 DISALLOW_COPY_AND_ASSIGN(WindowTreeClientFactory); 462 DISALLOW_COPY_AND_ASSIGN(WindowTreeClientFactory);
464 }; 463 };
465 464
466 } // namespace 465 } // namespace
467 466
468 class WindowTreeAppTest : public mojo::test::ApplicationTestBase, 467 class WindowTreeAppTest : public mojo::test::ApplicationTestBase,
469 public ApplicationDelegate { 468 public mojo::ShellClient {
470 public: 469 public:
471 WindowTreeAppTest() 470 WindowTreeAppTest()
472 : connection_id_1_(0), connection_id_2_(0), root_window_id_(0) {} 471 : connection_id_1_(0), connection_id_2_(0), root_window_id_(0) {}
473 ~WindowTreeAppTest() override {} 472 ~WindowTreeAppTest() override {}
474 473
475 protected: 474 protected:
476 // Returns the changes from the various connections. 475 // Returns the changes from the various connections.
477 std::vector<Change>* changes1() { return ws_client1_->tracker()->changes(); } 476 std::vector<Change>* changes1() { return ws_client1_->tracker()->changes(); }
478 std::vector<Change>* changes2() { return ws_client2_->tracker()->changes(); } 477 std::vector<Change>* changes2() { return ws_client2_->tracker()->changes(); }
479 std::vector<Change>* changes3() { return ws_client3_->tracker()->changes(); } 478 std::vector<Change>* changes3() { return ws_client3_->tracker()->changes(); }
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 client->WaitForOnEmbed(); 553 client->WaitForOnEmbed();
555 554
556 EXPECT_EQ("OnEmbed", 555 EXPECT_EQ("OnEmbed",
557 SingleChangeToDescription(*client->tracker()->changes())); 556 SingleChangeToDescription(*client->tracker()->changes()));
558 if (connection_id) 557 if (connection_id)
559 *connection_id = (*client->tracker()->changes())[0].connection_id; 558 *connection_id = (*client->tracker()->changes())[0].connection_id;
560 return client; 559 return client;
561 } 560 }
562 561
563 // ApplicationTestBase: 562 // ApplicationTestBase:
564 ApplicationDelegate* GetApplicationDelegate() override { return this; } 563 mojo::ShellClient* GetShellClient() override { return this; }
565 void SetUp() override { 564 void SetUp() override {
566 ApplicationTestBase::SetUp(); 565 ApplicationTestBase::SetUp();
567 client_factory_.reset(new WindowTreeClientFactory()); 566 client_factory_.reset(new WindowTreeClientFactory());
568 567
569 mojom::WindowTreeHostFactoryPtr factory; 568 mojom::WindowTreeHostFactoryPtr factory;
570 shell()->ConnectToService("mojo:mus", &factory); 569 shell()->ConnectToService("mojo:mus", &factory);
571 570
572 mojom::WindowTreeClientPtr tree_client_ptr; 571 mojom::WindowTreeClientPtr tree_client_ptr;
573 ws_client1_.reset(new TestWindowTreeClientImpl()); 572 ws_client1_.reset(new TestWindowTreeClientImpl());
574 ws_client1_->Bind(GetProxy(&tree_client_ptr)); 573 ws_client1_->Bind(GetProxy(&tree_client_ptr));
(...skipping 10 matching lines...) Expand all
585 // is the client id is not zero, but adding this as rest of code here 584 // is the client id is not zero, but adding this as rest of code here
586 // assumes 1. 585 // assumes 1.
587 ASSERT_GT((*changes1())[0].connection_id, 0); 586 ASSERT_GT((*changes1())[0].connection_id, 0);
588 connection_id_1_ = (*changes1())[0].connection_id; 587 connection_id_1_ = (*changes1())[0].connection_id;
589 ASSERT_FALSE((*changes1())[0].windows.empty()); 588 ASSERT_FALSE((*changes1())[0].windows.empty());
590 root_window_id_ = (*changes1())[0].windows[0].window_id; 589 root_window_id_ = (*changes1())[0].windows[0].window_id;
591 ASSERT_EQ(root_window_id_, ws_client1_->root_window_id()); 590 ASSERT_EQ(root_window_id_, ws_client1_->root_window_id());
592 changes1()->clear(); 591 changes1()->clear();
593 } 592 }
594 593
595 // ApplicationDelegate implementation. 594 // mojo::ShellClient implementation.
596 bool AcceptConnection(ApplicationConnection* connection) override { 595 bool AcceptConnection(Connection* connection) override {
597 connection->AddService(client_factory_.get()); 596 connection->AddService(client_factory_.get());
598 return true; 597 return true;
599 } 598 }
600 599
601 scoped_ptr<TestWindowTreeClientImpl> ws_client1_; 600 scoped_ptr<TestWindowTreeClientImpl> ws_client1_;
602 scoped_ptr<TestWindowTreeClientImpl> ws_client2_; 601 scoped_ptr<TestWindowTreeClientImpl> ws_client2_;
603 scoped_ptr<TestWindowTreeClientImpl> ws_client3_; 602 scoped_ptr<TestWindowTreeClientImpl> ws_client3_;
604 603
605 mojom::WindowTreeHostPtr host_; 604 mojom::WindowTreeHostPtr host_;
606 605
(...skipping 1258 matching lines...) Expand 10 before | Expand all | Expand 10 after
1865 // originating connection. 1864 // originating connection.
1866 1865
1867 // TODO(sky): make sure coverage of what was 1866 // TODO(sky): make sure coverage of what was
1868 // WindowManagerTest.SecondEmbedRoot_InitService and 1867 // WindowManagerTest.SecondEmbedRoot_InitService and
1869 // WindowManagerTest.MultipleEmbedRootsBeforeWTHReady gets added to window 1868 // WindowManagerTest.MultipleEmbedRootsBeforeWTHReady gets added to window
1870 // manager 1869 // manager
1871 // tests. 1870 // tests.
1872 1871
1873 } // namespace ws 1872 } // namespace ws
1874 } // namespace mus 1873 } // namespace mus
OLDNEW
« no previous file with comments | « components/mus/ws/window_manager_client_apptest.cc ('k') | components/pdf_viewer/pdf_viewer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698