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

Side by Side Diff: ash/mus/window_manager_unittest.cc

Issue 2706403004: mus: Makes ~WindowTreeClient reset context factory (Closed)
Patch Set: Created 3 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 | « no previous file | ui/aura/mus/window_tree_client.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 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 <map> 5 #include <map>
6 #include <memory> 6 #include <memory>
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 std::unique_ptr<aura::WindowTreeHostMus> window_tree_host_; 59 std::unique_ptr<aura::WindowTreeHostMus> window_tree_host_;
60 60
61 DISALLOW_COPY_AND_ASSIGN(WindowTreeClientDelegate); 61 DISALLOW_COPY_AND_ASSIGN(WindowTreeClientDelegate);
62 }; 62 };
63 63
64 class WindowManagerTest : public service_manager::test::ServiceTest { 64 class WindowManagerTest : public service_manager::test::ServiceTest {
65 public: 65 public:
66 WindowManagerTest() : service_manager::test::ServiceTest("mash_unittests") {} 66 WindowManagerTest() : service_manager::test::ServiceTest("mash_unittests") {}
67 ~WindowManagerTest() override {} 67 ~WindowManagerTest() override {}
68 68
69 // service_manager::test::ServiceTest:
70 void SetUp() override {
71 service_manager::test::ServiceTest::SetUp();
72
73 // This test connects to the real mus. This results in
74 // aura::WindowTreeClient resetting the context_factory on Env. As all
75 // tests share the same Env (see mash_test_suite) we need to restore the
76 // context_factory when done.
77 aura::Env* env = aura::Env::GetInstance();
78 initial_context_factory_ = env->context_factory();
79 initial_context_factory_private_ = env->context_factory_private();
80 }
81
82 void TearDown() override {
83 aura::Env* env = aura::Env::GetInstance();
84 env->set_context_factory(initial_context_factory_);
85 env->set_context_factory_private(initial_context_factory_private_);
86 }
87
88 private: 69 private:
89 ui::ContextFactory* initial_context_factory_ = nullptr;
90 ui::ContextFactoryPrivate* initial_context_factory_private_ = nullptr;
91
92 DISALLOW_COPY_AND_ASSIGN(WindowManagerTest); 70 DISALLOW_COPY_AND_ASSIGN(WindowManagerTest);
93 }; 71 };
94 72
95 void OnEmbed(bool success) { 73 void OnEmbed(bool success) {
96 ASSERT_TRUE(success); 74 ASSERT_TRUE(success);
97 } 75 }
98 76
99 TEST_F(WindowManagerTest, OpenWindow) { 77 TEST_F(WindowManagerTest, OpenWindow) {
100 display::ScreenBase screen; 78 display::ScreenBase screen;
101 screen.display_list().AddDisplay( 79 screen.display_list().AddDisplay(
(...skipping 27 matching lines...) Expand all
129 client.Embed(child_window, std::move(tree_client), 0u, base::Bind(&OnEmbed)); 107 client.Embed(child_window, std::move(tree_client), 0u, base::Bind(&OnEmbed));
130 aura::WindowTreeClient child_client(connector(), &window_tree_delegate, 108 aura::WindowTreeClient child_client(connector(), &window_tree_delegate,
131 nullptr, std::move(tree_client_request)); 109 nullptr, std::move(tree_client_request));
132 window_tree_delegate.WaitForEmbed(); 110 window_tree_delegate.WaitForEmbed();
133 ASSERT_TRUE(!child_client.GetRoots().empty()); 111 ASSERT_TRUE(!child_client.GetRoots().empty());
134 window_tree_delegate.DestroyWindowTreeHost(); 112 window_tree_delegate.DestroyWindowTreeHost();
135 } 113 }
136 114
137 } // namespace mus 115 } // namespace mus
138 } // namespace ash 116 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ui/aura/mus/window_tree_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698