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

Side by Side Diff: ui/views/mus/platform_test_helper_mus.cc

Issue 1882423004: Move shell service to toplevel shell namespace (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 8 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 | « ui/views/mus/native_widget_mus.cc ('k') | ui/views/mus/platform_window_mus.h » ('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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/memory/ptr_util.h" 6 #include "base/memory/ptr_util.h"
7 #include "base/run_loop.h" 7 #include "base/run_loop.h"
8 #include "services/shell/background/background_shell.h" 8 #include "services/shell/background/background_shell.h"
9 #include "services/shell/background/tests/test_catalog_store.h" 9 #include "services/shell/background/tests/test_catalog_store.h"
10 #include "services/shell/public/cpp/connector.h" 10 #include "services/shell/public/cpp/connector.h"
11 #include "services/shell/public/cpp/shell_client.h" 11 #include "services/shell/public/cpp/shell_client.h"
12 #include "services/shell/public/cpp/shell_connection.h" 12 #include "services/shell/public/cpp/shell_connection.h"
13 #include "ui/aura/env.h" 13 #include "ui/aura/env.h"
14 #include "ui/views/mus/window_manager_connection.h" 14 #include "ui/views/mus/window_manager_connection.h"
15 #include "ui/views/test/platform_test_helper.h" 15 #include "ui/views/test/platform_test_helper.h"
16 #include "ui/views/views_delegate.h" 16 #include "ui/views/views_delegate.h"
17 17
18 using mojo::shell::BackgroundShell; 18 using shell::BackgroundShell;
19 19
20 namespace views { 20 namespace views {
21 namespace { 21 namespace {
22 22
23 const char kTestName[] = "mojo:test-app"; 23 const char kTestName[] = "mojo:test-app";
24 24
25 class DefaultShellClient : public mojo::ShellClient { 25 class DefaultShellClient : public shell::ShellClient {
26 public: 26 public:
27 DefaultShellClient() {} 27 DefaultShellClient() {}
28 ~DefaultShellClient() override {} 28 ~DefaultShellClient() override {}
29 29
30 private: 30 private:
31 DISALLOW_COPY_AND_ASSIGN(DefaultShellClient); 31 DISALLOW_COPY_AND_ASSIGN(DefaultShellClient);
32 }; 32 };
33 33
34 std::unique_ptr<mojo::shell::TestCatalogStore> BuildTestCatalogStore() { 34 std::unique_ptr<shell::TestCatalogStore> BuildTestCatalogStore() {
35 std::unique_ptr<base::ListValue> apps(new base::ListValue); 35 std::unique_ptr<base::ListValue> apps(new base::ListValue);
36 apps->Append( 36 apps->Append(shell::BuildPermissiveSerializedAppInfo(kTestName, "test"));
37 mojo::shell::BuildPermissiveSerializedAppInfo(kTestName, "test")); 37 return base::WrapUnique(new shell::TestCatalogStore(std::move(apps)));
38 return base::WrapUnique(new mojo::shell::TestCatalogStore(std::move(apps)));
39 } 38 }
40 39
41 class PlatformTestHelperMus : public PlatformTestHelper { 40 class PlatformTestHelperMus : public PlatformTestHelper {
42 public: 41 public:
43 PlatformTestHelperMus() { 42 PlatformTestHelperMus() {
44 background_shell_.reset(new BackgroundShell); 43 background_shell_.reset(new BackgroundShell);
45 std::unique_ptr<BackgroundShell::InitParams> init_params( 44 std::unique_ptr<BackgroundShell::InitParams> init_params(
46 new BackgroundShell::InitParams); 45 new BackgroundShell::InitParams);
47 init_params->catalog_store = BuildTestCatalogStore(); 46 init_params->catalog_store = BuildTestCatalogStore();
48 background_shell_->Init(std::move(init_params)); 47 background_shell_->Init(std::move(init_params));
49 shell_client_.reset(new DefaultShellClient); 48 shell_client_.reset(new DefaultShellClient);
50 shell_connection_.reset(new mojo::ShellConnection( 49 shell_connection_.reset(new shell::ShellConnection(
51 shell_client_.get(), 50 shell_client_.get(),
52 background_shell_->CreateShellClientRequest(kTestName))); 51 background_shell_->CreateShellClientRequest(kTestName)));
53 52
54 // TODO(rockot): Remove this RunLoop. http://crbug.com/594852. 53 // TODO(rockot): Remove this RunLoop. http://crbug.com/594852.
55 base::RunLoop wait_loop; 54 base::RunLoop wait_loop;
56 shell_connection_->set_initialize_handler(wait_loop.QuitClosure()); 55 shell_connection_->set_initialize_handler(wait_loop.QuitClosure());
57 wait_loop.Run(); 56 wait_loop.Run();
58 57
59 // ui/views/mus requires a WindowManager running, for now use the desktop 58 // ui/views/mus requires a WindowManager running, for now use the desktop
60 // one. 59 // one.
61 mojo::Connector* connector = shell_connection_->connector(); 60 shell::Connector* connector = shell_connection_->connector();
62 connector->Connect("mojo:desktop_wm"); 61 connector->Connect("mojo:desktop_wm");
63 WindowManagerConnection::Create(connector); 62 WindowManagerConnection::Create(connector);
64 63
65 // On X we need to reset the ContextFactory before every NativeWidgetMus 64 // On X we need to reset the ContextFactory before every NativeWidgetMus
66 // is created. 65 // is created.
67 // TODO(sad): this is a hack, figure out a better solution. 66 // TODO(sad): this is a hack, figure out a better solution.
68 ViewsDelegate::GetInstance()->set_native_widget_factory(base::Bind( 67 ViewsDelegate::GetInstance()->set_native_widget_factory(base::Bind(
69 &PlatformTestHelperMus::CreateNativeWidgetMus, base::Unretained(this), 68 &PlatformTestHelperMus::CreateNativeWidgetMus, base::Unretained(this),
70 std::map<std::string, std::vector<uint8_t>>())); 69 std::map<std::string, std::vector<uint8_t>>()));
71 } 70 }
(...skipping 14 matching lines...) Expand all
86 ui::ContextFactory* factory = aura::Env::GetInstance()->context_factory(); 85 ui::ContextFactory* factory = aura::Env::GetInstance()->context_factory();
87 aura::Env::GetInstance()->set_context_factory(nullptr); 86 aura::Env::GetInstance()->set_context_factory(nullptr);
88 NativeWidget* result = 87 NativeWidget* result =
89 WindowManagerConnection::Get()->CreateNativeWidgetMus( 88 WindowManagerConnection::Get()->CreateNativeWidgetMus(
90 props, init_params, delegate); 89 props, init_params, delegate);
91 aura::Env::GetInstance()->set_context_factory(factory); 90 aura::Env::GetInstance()->set_context_factory(factory);
92 return result; 91 return result;
93 } 92 }
94 93
95 std::unique_ptr<BackgroundShell> background_shell_; 94 std::unique_ptr<BackgroundShell> background_shell_;
96 std::unique_ptr<mojo::ShellConnection> shell_connection_; 95 std::unique_ptr<shell::ShellConnection> shell_connection_;
97 std::unique_ptr<DefaultShellClient> shell_client_; 96 std::unique_ptr<DefaultShellClient> shell_client_;
98 97
99 DISALLOW_COPY_AND_ASSIGN(PlatformTestHelperMus); 98 DISALLOW_COPY_AND_ASSIGN(PlatformTestHelperMus);
100 }; 99 };
101 100
102 } // namespace 101 } // namespace
103 102
104 // static 103 // static
105 std::unique_ptr<PlatformTestHelper> PlatformTestHelper::Create() { 104 std::unique_ptr<PlatformTestHelper> PlatformTestHelper::Create() {
106 return base::WrapUnique(new PlatformTestHelperMus); 105 return base::WrapUnique(new PlatformTestHelperMus);
107 } 106 }
108 107
109 } // namespace views 108 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/mus/native_widget_mus.cc ('k') | ui/views/mus/platform_window_mus.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698