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

Side by Side Diff: mash/wm/window_manager_unittest.cc

Issue 1822133002: Converts mash_wm_apptests to unit tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update Created 4 years, 9 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 | « mash/wm/window_manager_apptest.cc ('k') | mojo/tools/data/apptests » ('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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 <stdint.h> 5 #include <stdint.h>
6 #include <utility> 6 #include <utility>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "components/mus/public/cpp/window.h" 10 #include "components/mus/public/cpp/window.h"
11 #include "components/mus/public/cpp/window_tree_connection.h" 11 #include "components/mus/public/cpp/window_tree_connection.h"
12 #include "components/mus/public/cpp/window_tree_delegate.h" 12 #include "components/mus/public/cpp/window_tree_delegate.h"
13 #include "components/mus/public/interfaces/window_tree.mojom.h" 13 #include "components/mus/public/interfaces/window_tree.mojom.h"
14 #include "mojo/shell/public/cpp/application_test_base.h" 14 #include "mojo/shell/public/cpp/shell_test.h"
15 15
16 namespace mash { 16 namespace mash {
17 namespace wm { 17 namespace wm {
18 18
19 class WindowTreeDelegateImpl : public mus::WindowTreeDelegate { 19 class WindowTreeDelegateImpl : public mus::WindowTreeDelegate {
20 public: 20 public:
21 WindowTreeDelegateImpl() {} 21 WindowTreeDelegateImpl() {}
22 ~WindowTreeDelegateImpl() override {} 22 ~WindowTreeDelegateImpl() override {}
23 23
24 private: 24 private:
25 // mus::WindowTreeDelegate: 25 // mus::WindowTreeDelegate:
26 void OnEmbed(mus::Window* root) override {} 26 void OnEmbed(mus::Window* root) override {}
27 void OnConnectionLost(mus::WindowTreeConnection* connection) override {} 27 void OnConnectionLost(mus::WindowTreeConnection* connection) override {}
28 28
29 DISALLOW_COPY_AND_ASSIGN(WindowTreeDelegateImpl); 29 DISALLOW_COPY_AND_ASSIGN(WindowTreeDelegateImpl);
30 }; 30 };
31 31
32 using WindowManagerAppTest = mojo::test::ApplicationTestBase; 32 class WindowManagerTest : public mojo::test::ShellTest {
33 public:
34 WindowManagerTest() : mojo::test::ShellTest("exe:mash_unittests") {}
35 ~WindowManagerTest() override {}
36
37 private:
38 DISALLOW_COPY_AND_ASSIGN(WindowManagerTest);
39 };
33 40
34 void OnEmbed(bool success) { 41 void OnEmbed(bool success) {
35 ASSERT_TRUE(success); 42 ASSERT_TRUE(success);
36 } 43 }
37 44
38 TEST_F(WindowManagerAppTest, OpenWindow) { 45 TEST_F(WindowManagerTest, OpenWindow) {
39 WindowTreeDelegateImpl window_tree_delegate; 46 WindowTreeDelegateImpl window_tree_delegate;
40 47
41 // Bring up the the desktop_wm. 48 // Bring up the the desktop_wm.
42 connector()->Connect("mojo:desktop_wm"); 49 connector()->Connect("mojo:desktop_wm");
43 50
44 // Connect to mus and create a new top level window. The request goes to 51 // Connect to mus and create a new top level window. The request goes to
45 // the |desktop_wm|, but is async. 52 // the |desktop_wm|, but is async.
46 scoped_ptr<mus::WindowTreeConnection> connection( 53 scoped_ptr<mus::WindowTreeConnection> connection(
47 mus::WindowTreeConnection::Create(&window_tree_delegate, connector())); 54 mus::WindowTreeConnection::Create(&window_tree_delegate, connector()));
48 mus::Window* top_level_window = connection->NewTopLevelWindow(nullptr); 55 mus::Window* top_level_window = connection->NewTopLevelWindow(nullptr);
49 ASSERT_TRUE(top_level_window); 56 ASSERT_TRUE(top_level_window);
50 mus::Window* child_window = connection->NewWindow(); 57 mus::Window* child_window = connection->NewWindow();
51 ASSERT_TRUE(child_window); 58 ASSERT_TRUE(child_window);
52 top_level_window->AddChild(child_window); 59 top_level_window->AddChild(child_window);
53 60
54 // Create another WindowTreeConnection by way of embedding in 61 // Create another WindowTreeConnection by way of embedding in
55 // |child_window|. This blocks until it succeeds. 62 // |child_window|. This blocks until it succeeds.
56 mus::mojom::WindowTreeClientPtr tree_client; 63 mus::mojom::WindowTreeClientPtr tree_client;
57 auto tree_client_request = GetProxy(&tree_client); 64 auto tree_client_request = GetProxy(&tree_client);
58 child_window->Embed(std::move(tree_client), base::Bind(&OnEmbed)); 65 child_window->Embed(std::move(tree_client), base::Bind(&OnEmbed));
59 scoped_ptr<mus::WindowTreeConnection> child_connection( 66 scoped_ptr<mus::WindowTreeConnection> child_connection(
60 mus::WindowTreeConnection::Create( 67 mus::WindowTreeConnection::Create(
61 &window_tree_delegate, std::move(tree_client_request), 68 &window_tree_delegate, std::move(tree_client_request),
62 mus::WindowTreeConnection::CreateType::WAIT_FOR_EMBED)); 69 mus::WindowTreeConnection::CreateType::WAIT_FOR_EMBED));
63 ASSERT_TRUE(!child_connection->GetRoots().empty()); 70 ASSERT_TRUE(!child_connection->GetRoots().empty());
64 } 71 }
65 72
66 } // namespace wm 73 } // namespace wm
67 } // namespace mash 74 } // namespace mash
OLDNEW
« no previous file with comments | « mash/wm/window_manager_apptest.cc ('k') | mojo/tools/data/apptests » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698