OLD | NEW |
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 Loading... |
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 triggers path that clobber the context_factory set on Env. As |
| 74 // all tests share the same Env (see mash_test_suite) we need to restore the |
| 75 // context_factory when done. |
| 76 aura::Env* env = aura::Env::GetInstance(); |
| 77 initial_context_factory_ = env->context_factory(); |
| 78 initial_context_factory_private_ = env->context_factory_private(); |
| 79 } |
| 80 |
| 81 void TearDown() override { |
| 82 aura::Env* env = aura::Env::GetInstance(); |
| 83 env->set_context_factory(initial_context_factory_); |
| 84 env->set_context_factory_private(initial_context_factory_private_); |
| 85 } |
| 86 |
69 private: | 87 private: |
| 88 ui::ContextFactory* initial_context_factory_; |
| 89 ui::ContextFactoryPrivate* initial_context_factory_private_; |
| 90 |
70 DISALLOW_COPY_AND_ASSIGN(WindowManagerTest); | 91 DISALLOW_COPY_AND_ASSIGN(WindowManagerTest); |
71 }; | 92 }; |
72 | 93 |
73 void OnEmbed(bool success) { | 94 void OnEmbed(bool success) { |
74 ASSERT_TRUE(success); | 95 ASSERT_TRUE(success); |
75 } | 96 } |
76 | 97 |
77 TEST_F(WindowManagerTest, OpenWindow) { | 98 TEST_F(WindowManagerTest, OpenWindow) { |
78 display::ScreenBase screen; | 99 display::ScreenBase screen; |
79 screen.display_list().AddDisplay( | 100 screen.display_list().AddDisplay( |
(...skipping 27 matching lines...) Expand all Loading... |
107 client.Embed(child_window, std::move(tree_client), 0u, base::Bind(&OnEmbed)); | 128 client.Embed(child_window, std::move(tree_client), 0u, base::Bind(&OnEmbed)); |
108 aura::WindowTreeClient child_client(connector(), &window_tree_delegate, | 129 aura::WindowTreeClient child_client(connector(), &window_tree_delegate, |
109 nullptr, std::move(tree_client_request)); | 130 nullptr, std::move(tree_client_request)); |
110 window_tree_delegate.WaitForEmbed(); | 131 window_tree_delegate.WaitForEmbed(); |
111 ASSERT_TRUE(!child_client.GetRoots().empty()); | 132 ASSERT_TRUE(!child_client.GetRoots().empty()); |
112 window_tree_delegate.DestroyWindowTreeHost(); | 133 window_tree_delegate.DestroyWindowTreeHost(); |
113 } | 134 } |
114 | 135 |
115 } // namespace mus | 136 } // namespace mus |
116 } // namespace ash | 137 } // namespace ash |
OLD | NEW |