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

Unified Diff: ash/mus/window_manager_unittest.cc

Issue 2556843002: Converts WindowManagerTest.OpenWindow to aura-mus (Closed)
Patch Set: not relative Created 4 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/mus/window_manager.cc ('k') | mash/unittests_manifest.json » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/mus/window_manager_unittest.cc
diff --git a/ash/mus/window_manager_unittest.cc b/ash/mus/window_manager_unittest.cc
index b2c689df18bb0a090f782dd3e4d1fa4430e872f9..82aea1bc64ab74824092b980654a4a8f56c81408 100644
--- a/ash/mus/window_manager_unittest.cc
+++ b/ash/mus/window_manager_unittest.cc
@@ -2,31 +2,62 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <map>
#include <memory>
+#include <vector>
#include "base/bind.h"
#include "base/macros.h"
+#include "base/run_loop.h"
#include "services/service_manager/public/cpp/service_test.h"
-#include "services/ui/public/cpp/window.h"
-#include "services/ui/public/cpp/window_tree_client.h"
-#include "services/ui/public/cpp/window_tree_client_delegate.h"
+#include "services/ui/public/cpp/property_type_converters.h"
#include "services/ui/public/interfaces/window_tree.mojom.h"
+#include "ui/aura/env.h"
+#include "ui/aura/mus/property_converter.h"
+#include "ui/aura/mus/window_tree_client.h"
+#include "ui/aura/mus/window_tree_client_delegate.h"
+#include "ui/aura/mus/window_tree_host_mus.h"
+#include "ui/aura/window.h"
+#include "ui/display/display.h"
+#include "ui/display/display_list.h"
+#include "ui/display/screen_base.h"
+#include "ui/wm/core/capture_controller.h"
+#include "ui/wm/core/wm_state.h"
namespace ash {
namespace mus {
-class WindowTreeClientDelegate : public ui::WindowTreeClientDelegate {
+class WindowTreeClientDelegate : public aura::WindowTreeClientDelegate {
public:
WindowTreeClientDelegate() {}
~WindowTreeClientDelegate() override {}
+ void WaitForEmbed() { run_loop_.Run(); }
+
+ void DestroyWindowTreeHost() { window_tree_host_.reset(); }
+
private:
- // ui::WindowTreeClientDelegate:
- void OnEmbed(ui::Window* root) override {}
- void OnEmbedRootDestroyed(ui::Window* root) override {}
- void OnLostConnection(ui::WindowTreeClient* client) override {}
+ // aura::WindowTreeClientDelegate:
+ void OnEmbed(
+ std::unique_ptr<aura::WindowTreeHostMus> window_tree_host) override {
+ window_tree_host_ = std::move(window_tree_host);
+ run_loop_.Quit();
+ }
+ void OnEmbedRootDestroyed(aura::Window* root) override {}
+ void OnLostConnection(aura::WindowTreeClient* client) override {}
void OnPointerEventObserved(const ui::PointerEvent& event,
- ui::Window* target) override {}
+ aura::Window* target) override {}
+ aura::client::CaptureClient* GetCaptureClient() override {
+ return wm_state_.capture_controller();
+ }
+ aura::PropertyConverter* GetPropertyConverter() override {
+ return &property_converter_;
+ }
+
+ base::RunLoop run_loop_;
+ wm::WMState wm_state_;
+ aura::PropertyConverter property_converter_;
+ std::unique_ptr<aura::WindowTreeHostMus> window_tree_host_;
DISALLOW_COPY_AND_ASSIGN(WindowTreeClientDelegate);
};
@@ -48,32 +79,41 @@ void OnEmbed(bool success) {
// (ash::MaterialDesignController::IsShelfMaterial()). See
// crbug.com/660194 and crbug.com/642879.
// TODO(rockot): Reenable this test.
-// TODO(sky): convert to using aura.
TEST_F(WindowManagerTest, DISABLED_OpenWindow) {
+ display::ScreenBase screen;
+ screen.display_list().AddDisplay(
+ display::Display(1, gfx::Rect(0, 0, 200, 200)),
+ display::DisplayList::Type::PRIMARY);
+ display::Screen::SetScreenInstance(&screen);
+
WindowTreeClientDelegate window_tree_delegate;
connector()->Connect("ash");
// Connect to mus and create a new top level window. The request goes to
// |ash|, but is async.
- std::unique_ptr<ui::WindowTreeClient> client(
- new ui::WindowTreeClient(&window_tree_delegate));
- client->ConnectViaWindowTreeFactory(connector());
- ui::Window* top_level_window = client->NewTopLevelWindow(nullptr);
- ASSERT_TRUE(top_level_window);
- ui::Window* child_window = client->NewWindow();
- ASSERT_TRUE(child_window);
- top_level_window->AddChild(child_window);
+ aura::WindowTreeClient client(connector(), &window_tree_delegate);
+ client.ConnectViaWindowTreeFactory();
+ aura::Env::GetInstance()->SetWindowTreeClient(&client);
+ std::map<std::string, std::vector<uint8_t>> properties;
+ properties[ui::mojom::WindowManager::kWindowType_Property] =
+ mojo::ConvertTo<std::vector<uint8_t>>(
+ static_cast<int32_t>(ui::mojom::WindowType::WINDOW));
+ aura::WindowTreeHostMus window_tree_host_mus(&client, &properties);
+ aura::Window* child_window = new aura::Window(nullptr);
+ child_window->Init(ui::LAYER_NOT_DRAWN);
+ window_tree_host_mus.window()->AddChild(child_window);
// Create another WindowTreeClient by way of embedding in
// |child_window|. This blocks until it succeeds.
ui::mojom::WindowTreeClientPtr tree_client;
auto tree_client_request = GetProxy(&tree_client);
- child_window->Embed(std::move(tree_client), base::Bind(&OnEmbed));
- std::unique_ptr<ui::WindowTreeClient> child_client(new ui::WindowTreeClient(
- &window_tree_delegate, nullptr, std::move(tree_client_request)));
- child_client->WaitForEmbed();
- ASSERT_TRUE(!child_client->GetRoots().empty());
+ client.Embed(child_window, std::move(tree_client), 0u, base::Bind(&OnEmbed));
+ aura::WindowTreeClient child_client(connector(), &window_tree_delegate,
+ nullptr, std::move(tree_client_request));
+ window_tree_delegate.WaitForEmbed();
+ ASSERT_TRUE(!child_client.GetRoots().empty());
+ window_tree_delegate.DestroyWindowTreeHost();
}
} // namespace mus
« no previous file with comments | « ash/mus/window_manager.cc ('k') | mash/unittests_manifest.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698