| 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" |
| 11 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
| 12 #include "services/service_manager/public/cpp/service_test.h" | 12 #include "services/service_manager/public/cpp/service_test.h" |
| 13 #include "services/ui/public/cpp/property_type_converters.h" | 13 #include "services/ui/public/cpp/property_type_converters.h" |
| 14 #include "services/ui/public/interfaces/window_tree.mojom.h" | 14 #include "services/ui/public/interfaces/window_tree.mojom.h" |
| 15 #include "ui/aura/env.h" | 15 #include "ui/aura/env.h" |
| 16 #include "ui/aura/mus/property_converter.h" | 16 #include "ui/aura/mus/property_converter.h" |
| 17 #include "ui/aura/mus/window_tree_client.h" | 17 #include "ui/aura/mus/window_tree_client.h" |
| 18 #include "ui/aura/mus/window_tree_client_delegate.h" | 18 #include "ui/aura/mus/window_tree_client_delegate.h" |
| 19 #include "ui/aura/mus/window_tree_host_mus.h" | 19 #include "ui/aura/mus/window_tree_host_mus.h" |
| 20 #include "ui/aura/test/env_test_helper.h" |
| 20 #include "ui/aura/window.h" | 21 #include "ui/aura/window.h" |
| 21 #include "ui/display/display.h" | 22 #include "ui/display/display.h" |
| 22 #include "ui/display/display_list.h" | 23 #include "ui/display/display_list.h" |
| 23 #include "ui/display/screen_base.h" | 24 #include "ui/display/screen_base.h" |
| 24 #include "ui/wm/core/capture_controller.h" | 25 #include "ui/wm/core/capture_controller.h" |
| 25 #include "ui/wm/core/wm_state.h" | 26 #include "ui/wm/core/wm_state.h" |
| 26 | 27 |
| 27 namespace ash { | 28 namespace ash { |
| 28 namespace mus { | 29 namespace mus { |
| 29 | 30 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 ~WindowManagerTest() override {} | 70 ~WindowManagerTest() override {} |
| 70 | 71 |
| 71 private: | 72 private: |
| 72 DISALLOW_COPY_AND_ASSIGN(WindowManagerTest); | 73 DISALLOW_COPY_AND_ASSIGN(WindowManagerTest); |
| 73 }; | 74 }; |
| 74 | 75 |
| 75 void OnEmbed(bool success) { | 76 void OnEmbed(bool success) { |
| 76 ASSERT_TRUE(success); | 77 ASSERT_TRUE(success); |
| 77 } | 78 } |
| 78 | 79 |
| 79 // Fails when the Ash material design shelf is enabled by default | 80 TEST_F(WindowManagerTest, OpenWindow) { |
| 80 // (ash::MaterialDesignController::IsShelfMaterial()). See | |
| 81 // crbug.com/660194 and crbug.com/642879. | |
| 82 // TODO(rockot): Reenable this test. | |
| 83 TEST_F(WindowManagerTest, DISABLED_OpenWindow) { | |
| 84 display::ScreenBase screen; | 81 display::ScreenBase screen; |
| 85 screen.display_list().AddDisplay( | 82 screen.display_list().AddDisplay( |
| 86 display::Display(1, gfx::Rect(0, 0, 200, 200)), | 83 display::Display(1, gfx::Rect(0, 0, 200, 200)), |
| 87 display::DisplayList::Type::PRIMARY); | 84 display::DisplayList::Type::PRIMARY); |
| 88 display::Screen::SetScreenInstance(&screen); | 85 display::Screen::SetScreenInstance(&screen); |
| 89 | 86 |
| 90 WindowTreeClientDelegate window_tree_delegate; | 87 WindowTreeClientDelegate window_tree_delegate; |
| 91 | 88 |
| 92 connector()->Connect("ash"); | 89 connector()->Connect("ash"); |
| 93 | 90 |
| 94 // Connect to mus and create a new top level window. The request goes to | 91 // Connect to mus and create a new top level window. The request goes to |
| 95 // |ash|, but is async. | 92 // |ash|, but is async. |
| 96 aura::WindowTreeClient client(connector(), &window_tree_delegate); | 93 aura::WindowTreeClient client(connector(), &window_tree_delegate); |
| 97 client.ConnectViaWindowTreeFactory(); | 94 client.ConnectViaWindowTreeFactory(); |
| 98 aura::Env::GetInstance()->SetWindowTreeClient(&client); | 95 aura::test::EnvTestHelper().SetWindowTreeClient(&client); |
| 99 std::map<std::string, std::vector<uint8_t>> properties; | 96 std::map<std::string, std::vector<uint8_t>> properties; |
| 100 properties[ui::mojom::WindowManager::kWindowType_InitProperty] = | 97 properties[ui::mojom::WindowManager::kWindowType_InitProperty] = |
| 101 mojo::ConvertTo<std::vector<uint8_t>>( | 98 mojo::ConvertTo<std::vector<uint8_t>>( |
| 102 static_cast<int32_t>(ui::mojom::WindowType::WINDOW)); | 99 static_cast<int32_t>(ui::mojom::WindowType::WINDOW)); |
| 103 aura::WindowTreeHostMus window_tree_host_mus(&client, &properties); | 100 aura::WindowTreeHostMus window_tree_host_mus(&client, &properties); |
| 101 window_tree_host_mus.InitHost(); |
| 104 aura::Window* child_window = new aura::Window(nullptr); | 102 aura::Window* child_window = new aura::Window(nullptr); |
| 105 child_window->Init(ui::LAYER_NOT_DRAWN); | 103 child_window->Init(ui::LAYER_NOT_DRAWN); |
| 106 window_tree_host_mus.window()->AddChild(child_window); | 104 window_tree_host_mus.window()->AddChild(child_window); |
| 107 | 105 |
| 108 // Create another WindowTreeClient by way of embedding in | 106 // Create another WindowTreeClient by way of embedding in |
| 109 // |child_window|. This blocks until it succeeds. | 107 // |child_window|. This blocks until it succeeds. |
| 110 ui::mojom::WindowTreeClientPtr tree_client; | 108 ui::mojom::WindowTreeClientPtr tree_client; |
| 111 auto tree_client_request = GetProxy(&tree_client); | 109 auto tree_client_request = GetProxy(&tree_client); |
| 112 client.Embed(child_window, std::move(tree_client), 0u, base::Bind(&OnEmbed)); | 110 client.Embed(child_window, std::move(tree_client), 0u, base::Bind(&OnEmbed)); |
| 113 aura::WindowTreeClient child_client(connector(), &window_tree_delegate, | 111 aura::WindowTreeClient child_client(connector(), &window_tree_delegate, |
| 114 nullptr, std::move(tree_client_request)); | 112 nullptr, std::move(tree_client_request)); |
| 115 window_tree_delegate.WaitForEmbed(); | 113 window_tree_delegate.WaitForEmbed(); |
| 116 ASSERT_TRUE(!child_client.GetRoots().empty()); | 114 ASSERT_TRUE(!child_client.GetRoots().empty()); |
| 117 window_tree_delegate.DestroyWindowTreeHost(); | 115 window_tree_delegate.DestroyWindowTreeHost(); |
| 118 } | 116 } |
| 119 | 117 |
| 120 } // namespace mus | 118 } // namespace mus |
| 121 } // namespace ash | 119 } // namespace ash |
| OLD | NEW |