Chromium Code Reviews| 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 connects to the real mus. This results in | |
| 74 // aura::WindowTreeClient resetting the context_factory on Env. As all | |
|
msw
2017/02/22 06:25:48
q: Should WindowTreeClient's dtor reset the Env in
sky
2017/02/22 16:32:05
If you mean reset the context factor, that sounds
sky
2017/02/22 17:53:49
Patch for reset context factory in ~WindowTreeClie
| |
| 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 | |
| 69 private: | 88 private: |
| 89 ui::ContextFactory* initial_context_factory_ = nullptr; | |
| 90 ui::ContextFactoryPrivate* initial_context_factory_private_ = nullptr; | |
| 91 | |
| 70 DISALLOW_COPY_AND_ASSIGN(WindowManagerTest); | 92 DISALLOW_COPY_AND_ASSIGN(WindowManagerTest); |
| 71 }; | 93 }; |
| 72 | 94 |
| 73 void OnEmbed(bool success) { | 95 void OnEmbed(bool success) { |
| 74 ASSERT_TRUE(success); | 96 ASSERT_TRUE(success); |
| 75 } | 97 } |
| 76 | 98 |
| 77 TEST_F(WindowManagerTest, OpenWindow) { | 99 TEST_F(WindowManagerTest, OpenWindow) { |
| 78 display::ScreenBase screen; | 100 display::ScreenBase screen; |
| 79 screen.display_list().AddDisplay( | 101 screen.display_list().AddDisplay( |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 107 client.Embed(child_window, std::move(tree_client), 0u, base::Bind(&OnEmbed)); | 129 client.Embed(child_window, std::move(tree_client), 0u, base::Bind(&OnEmbed)); |
| 108 aura::WindowTreeClient child_client(connector(), &window_tree_delegate, | 130 aura::WindowTreeClient child_client(connector(), &window_tree_delegate, |
| 109 nullptr, std::move(tree_client_request)); | 131 nullptr, std::move(tree_client_request)); |
| 110 window_tree_delegate.WaitForEmbed(); | 132 window_tree_delegate.WaitForEmbed(); |
| 111 ASSERT_TRUE(!child_client.GetRoots().empty()); | 133 ASSERT_TRUE(!child_client.GetRoots().empty()); |
| 112 window_tree_delegate.DestroyWindowTreeHost(); | 134 window_tree_delegate.DestroyWindowTreeHost(); |
| 113 } | 135 } |
| 114 | 136 |
| 115 } // namespace mus | 137 } // namespace mus |
| 116 } // namespace ash | 138 } // namespace ash |
| OLD | NEW |