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

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

Issue 1982963002: Reland: mus: Add views_mus_interactive_ui_tests target (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix size_t to int warning on Windows Created 4 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
« no previous file with comments | « ui/views/mus/views_mus_test_suite.h ('k') | ui/views/run_all_unittests.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 "ui/views/run_all_unittests.h" 5 #include "ui/views/mus/views_mus_test_suite.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/command_line.h"
10 #include "base/files/file_path.h"
9 #include "base/run_loop.h" 11 #include "base/run_loop.h"
10 #include "base/synchronization/waitable_event.h" 12 #include "base/synchronization/waitable_event.h"
11 #include "base/threading/simple_thread.h" 13 #include "base/threading/simple_thread.h"
12 #include "base/threading/thread.h" 14 #include "base/threading/thread.h"
13 #include "services/shell/background/background_shell.h" 15 #include "services/shell/background/background_shell.h"
14 #include "services/shell/public/cpp/connector.h" 16 #include "services/shell/public/cpp/connector.h"
15 #include "services/shell/public/cpp/shell_client.h" 17 #include "services/shell/public/cpp/shell_client.h"
16 #include "services/shell/public/cpp/shell_connection.h" 18 #include "services/shell/public/cpp/shell_connection.h"
17 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
18 #include "ui/views/mus/window_manager_connection.h" 20 #include "ui/views/mus/window_manager_connection.h"
19 #include "ui/views/test/platform_test_helper.h" 21 #include "ui/views/test/platform_test_helper.h"
20 #include "ui/views/views_delegate.h" 22 #include "ui/views/views_delegate.h"
21 23
22 namespace views { 24 namespace views {
23 namespace { 25 namespace {
24 26
25 const char kTestName[] = "exe:views_mus_unittests";
26
27 class DefaultShellClient : public shell::ShellClient { 27 class DefaultShellClient : public shell::ShellClient {
28 public: 28 public:
29 DefaultShellClient() {} 29 DefaultShellClient() {}
30 ~DefaultShellClient() override {} 30 ~DefaultShellClient() override {}
31 31
32 private: 32 private:
33 DISALLOW_COPY_AND_ASSIGN(DefaultShellClient); 33 DISALLOW_COPY_AND_ASSIGN(DefaultShellClient);
34 }; 34 };
35 35
36 class PlatformTestHelperMus : public PlatformTestHelper { 36 class PlatformTestHelperMus : public PlatformTestHelper {
37 public: 37 public:
38 PlatformTestHelperMus() {} 38 PlatformTestHelperMus() {}
39 ~PlatformTestHelperMus() override {} 39 ~PlatformTestHelperMus() override {}
40 40
41 // PlatformTestHelper:
42 bool IsMus() const override { return true; }
43
44 private: 41 private:
45 DISALLOW_COPY_AND_ASSIGN(PlatformTestHelperMus); 42 DISALLOW_COPY_AND_ASSIGN(PlatformTestHelperMus);
46 }; 43 };
47 44
48 std::unique_ptr<PlatformTestHelper> CreatePlatformTestHelper( 45 std::unique_ptr<PlatformTestHelper> CreatePlatformTestHelper(
49 shell::Connector* connector, 46 shell::Connector* connector,
50 const shell::Identity& identity) { 47 const shell::Identity& identity) {
51 if (!WindowManagerConnection::Exists()) 48 if (!WindowManagerConnection::Exists())
52 WindowManagerConnection::Create(connector, identity); 49 WindowManagerConnection::Create(connector, identity);
53 return base::WrapUnique(new PlatformTestHelperMus); 50 return base::WrapUnique(new PlatformTestHelperMus);
54 } 51 }
55 52
53 } // namespace
54
56 class ShellConnection { 55 class ShellConnection {
57 public: 56 public:
58 ShellConnection() : thread_("Persistent shell connections") { 57 ShellConnection() : thread_("Persistent shell connections") {
59 base::WaitableEvent wait(false, false); 58 base::WaitableEvent wait(false, false);
60 base::Thread::Options options; 59 base::Thread::Options options;
61 thread_.StartWithOptions(options); 60 thread_.StartWithOptions(options);
62 thread_.task_runner()->PostTask( 61 thread_.task_runner()->PostTask(
63 FROM_HERE, base::Bind(&ShellConnection::SetUpConnections, 62 FROM_HERE, base::Bind(&ShellConnection::SetUpConnections,
64 base::Unretained(this), &wait)); 63 base::Unretained(this), &wait));
65 wait.Wait(); 64 wait.Wait();
(...skipping 16 matching lines...) Expand all
82 wait.Wait(); 81 wait.Wait();
83 } 82 }
84 83
85 private: 84 private:
86 void SetUpConnections(base::WaitableEvent* wait) { 85 void SetUpConnections(base::WaitableEvent* wait) {
87 background_shell_.reset(new shell::BackgroundShell); 86 background_shell_.reset(new shell::BackgroundShell);
88 background_shell_->Init(nullptr); 87 background_shell_->Init(nullptr);
89 shell_client_.reset(new DefaultShellClient); 88 shell_client_.reset(new DefaultShellClient);
90 shell_connection_.reset(new shell::ShellConnection( 89 shell_connection_.reset(new shell::ShellConnection(
91 shell_client_.get(), 90 shell_client_.get(),
92 background_shell_->CreateShellClientRequest(kTestName))); 91 background_shell_->CreateShellClientRequest(GetTestName())));
93 92
94 // ui/views/mus requires a WindowManager running, for now use the desktop 93 // ui/views/mus requires a WindowManager running, for now use the desktop
95 // one. 94 // one.
96 shell::Connector* connector = shell_connection_->connector(); 95 shell::Connector* connector = shell_connection_->connector();
97 connector->Connect("mojo:desktop_wm"); 96 connector->Connect("mojo:desktop_wm");
98 shell_connector_ = connector->Clone(); 97 shell_connector_ = connector->Clone();
99 shell_identity_ = shell_connection_->identity(); 98 shell_identity_ = shell_connection_->identity();
100 wait->Signal(); 99 wait->Signal();
101 } 100 }
102 101
103 void TearDownConnections(base::WaitableEvent* wait) { 102 void TearDownConnections(base::WaitableEvent* wait) {
104 shell_connection_.reset(); 103 shell_connection_.reset();
105 wait->Signal(); 104 wait->Signal();
106 } 105 }
107 106
107 // Returns the name of the test executable, e.g. "exe:views_mus_unittests".
108 std::string GetTestName() {
109 base::FilePath executable = base::CommandLine::ForCurrentProcess()
110 ->GetProgram()
111 .BaseName()
112 .RemoveExtension();
113 return std::string("exe:") + executable.MaybeAsASCII();
114 }
115
108 base::Thread thread_; 116 base::Thread thread_;
109 std::unique_ptr<shell::BackgroundShell> background_shell_; 117 std::unique_ptr<shell::BackgroundShell> background_shell_;
110 std::unique_ptr<shell::ShellConnection> shell_connection_; 118 std::unique_ptr<shell::ShellConnection> shell_connection_;
111 std::unique_ptr<DefaultShellClient> shell_client_; 119 std::unique_ptr<DefaultShellClient> shell_client_;
112 std::unique_ptr<shell::Connector> shell_connector_; 120 std::unique_ptr<shell::Connector> shell_connector_;
113 shell::Identity shell_identity_; 121 shell::Identity shell_identity_;
114 122
115 DISALLOW_COPY_AND_ASSIGN(ShellConnection); 123 DISALLOW_COPY_AND_ASSIGN(ShellConnection);
116 }; 124 };
117 125
118 class ViewMusTestSuite : public ViewTestSuite { 126 ViewsMusTestSuite::ViewsMusTestSuite(int argc, char** argv)
119 public: 127 : ViewTestSuite(argc, argv) {}
120 ViewMusTestSuite(int argc, char** argv) : ViewTestSuite(argc, argv) {}
121 128
122 protected: 129 ViewsMusTestSuite::~ViewsMusTestSuite() {}
123 void Initialize() override {
124 ViewTestSuite::Initialize();
125 shell_connections_.reset(new ShellConnection);
126 }
127 130
128 void Shutdown() override { 131 void ViewsMusTestSuite::Initialize() {
129 shell_connections_.reset(); 132 PlatformTestHelper::SetIsMus();
130 ViewTestSuite::Shutdown(); 133 ViewTestSuite::Initialize();
131 } 134 shell_connections_.reset(new ShellConnection);
135 }
132 136
133 private: 137 void ViewsMusTestSuite::Shutdown() {
134 std::unique_ptr<ShellConnection> shell_connections_; 138 shell_connections_.reset();
139 ViewTestSuite::Shutdown();
140 }
135 141
136 DISALLOW_COPY_AND_ASSIGN(ViewMusTestSuite);
137 };
138
139 } // namespace
140 } // namespace views 142 } // namespace views
141
142 int MasterProcessMain(int argc, char** argv) {
143 return views::ViewMusTestSuite(argc, argv).RunTests();
144 }
OLDNEW
« no previous file with comments | « ui/views/mus/views_mus_test_suite.h ('k') | ui/views/run_all_unittests.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698