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

Side by Side Diff: components/window_manager/window_manager_apptest.cc

Issue 1138073007: Nukes the windowmanager interface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge Created 5 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "base/bind.h"
6 #include "base/run_loop.h"
7 #include "components/view_manager/public/cpp/view.h"
8 #include "components/view_manager/public/cpp/view_manager_client_factory.h"
9 #include "components/view_manager/public/cpp/view_manager_delegate.h"
10 #include "components/window_manager/public/interfaces/window_manager.mojom.h"
11 #include "mojo/application/application_test_base_chromium.h"
12 #include "mojo/application/public/cpp/application_delegate.h"
13 #include "mojo/application/public/cpp/application_impl.h"
14 #include "mojo/application/public/cpp/service_provider_impl.h"
15 #include "third_party/mojo/src/mojo/public/cpp/system/macros.h"
16
17 namespace mojo {
18 namespace {
19
20 // TestApplication's view is embedded by the window manager.
21 class TestApplication : public ApplicationDelegate, public ViewManagerDelegate {
22 public:
23 TestApplication() : root_(nullptr) {}
24 ~TestApplication() override {}
25
26 View* root() const { return root_; }
27
28 void set_embed_callback(const base::Closure& callback) {
29 embed_callback_ = callback;
30 }
31
32 private:
33 // ApplicationDelegate:
34 void Initialize(ApplicationImpl* app) override {
35 view_manager_client_factory_.reset(
36 new ViewManagerClientFactory(app->shell(), this));
37 }
38
39 bool ConfigureIncomingConnection(ApplicationConnection* connection) override {
40 connection->AddService(view_manager_client_factory_.get());
41 return true;
42 }
43
44 // ViewManagerDelegate:
45 void OnEmbed(View* root,
46 InterfaceRequest<ServiceProvider> services,
47 ServiceProviderPtr exposed_services) override {
48 root_ = root;
49 embed_callback_.Run();
50 }
51 void OnViewManagerDisconnected(ViewManager* view_manager) override {}
52
53 View* root_;
54 base::Closure embed_callback_;
55 scoped_ptr<ViewManagerClientFactory> view_manager_client_factory_;
56
57 MOJO_DISALLOW_COPY_AND_ASSIGN(TestApplication);
58 };
59
60 class WindowManagerApplicationTest : public test::ApplicationTestBase {
61 public:
62 WindowManagerApplicationTest() {}
63 ~WindowManagerApplicationTest() override {}
64
65 protected:
66 // ApplicationTestBase:
67 void SetUp() override {
68 ApplicationTestBase::SetUp();
69 application_impl()->ConnectToService("mojo:test_window_manager",
70 &window_manager_);
71 }
72 ApplicationDelegate* GetApplicationDelegate() override {
73 return &test_application_;
74 }
75
76 void EmbedApplicationWithURL(const std::string& url) {
77 window_manager_->Embed(url, nullptr, nullptr);
78
79 base::RunLoop run_loop;
80 test_application_.set_embed_callback(run_loop.QuitClosure());
81 run_loop.Run();
82 }
83
84 WindowManagerPtr window_manager_;
85 TestApplication test_application_;
86
87 private:
88 MOJO_DISALLOW_COPY_AND_ASSIGN(WindowManagerApplicationTest);
89 };
90
91 TEST_F(WindowManagerApplicationTest, Embed) {
92 EXPECT_EQ(nullptr, test_application_.root());
93 EmbedApplicationWithURL(application_impl()->url());
94 EXPECT_NE(nullptr, test_application_.root());
95 }
96
97 } // namespace
98 } // namespace mojo
OLDNEW
« no previous file with comments | « components/window_manager/window_manager_app.cc ('k') | components/window_manager/window_manager_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698