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

Unified Diff: ash/mus/top_level_window_factory_unittest.cc

Issue 2840393002: chromeos: converts TopLevelWindowFactoryTest to AshTestBase (Closed)
Patch Set: remove duplicate function Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/mus/test/wm_test_base.cc ('k') | ash/test/ash_test_base.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/mus/top_level_window_factory_unittest.cc
diff --git a/ash/mus/top_level_window_factory_unittest.cc b/ash/mus/top_level_window_factory_unittest.cc
index 36365f0481f42ac8816a1aab2ed08bc8478f14fa..7af8fe41a296ae7307bc26247775c738b730ebff 100644
--- a/ash/mus/top_level_window_factory_unittest.cc
+++ b/ash/mus/top_level_window_factory_unittest.cc
@@ -10,16 +10,20 @@
#include <string>
#include <vector>
-#include "ash/mus/test/wm_test_base.h"
#include "ash/mus/window_manager.h"
#include "ash/mus/window_manager_application.h"
-#include "ash/shell_port.h"
+#include "ash/shell.h"
#include "ash/test/ash_test.h"
#include "ash/test/ash_test_base.h"
#include "ash/test/ash_test_helper.h"
-#include "ash/wm_window.h"
+#include "ash/wm/window_properties.h"
+#include "services/ui/public/cpp/property_type_converters.h"
+#include "ui/aura/mus/property_converter.h"
#include "ui/aura/window.h"
#include "ui/display/screen.h"
+#include "ui/gfx/geometry/rect.h"
+#include "ui/gfx/test/gfx_util.h"
+#include "ui/wm/core/window_util.h"
namespace ash {
@@ -29,28 +33,47 @@ int64_t GetDisplayId(aura::Window* window) {
return display::Screen::GetScreen()->GetDisplayNearestWindow(window).id();
}
+aura::Window* CreateFullscreenTestWindow(mus::WindowManager* window_manager,
+ int64_t display_id) {
+ std::map<std::string, std::vector<uint8_t>> properties;
+ properties[ui::mojom::WindowManager::kShowState_Property] =
+ mojo::ConvertTo<std::vector<uint8_t>>(
+ static_cast<aura::PropertyConverter::PrimitiveType>(
+ ui::mojom::ShowState::FULLSCREEN));
+ if (display_id != display::kInvalidDisplayId) {
+ properties[ui::mojom::WindowManager::kDisplayId_InitProperty] =
+ mojo::ConvertTo<std::vector<uint8_t>>(display_id);
+ }
+ aura::Window* window = mus::CreateAndParentTopLevelWindow(
+ window_manager, ui::mojom::WindowType::WINDOW, &properties);
+ window->Show();
+ return window;
+}
+
} // namespace
-using TopLevelWindowFactoryTest = AshTest;
+using TopLevelWindowFactoryTest = test::AshTestBase;
TEST_F(TopLevelWindowFactoryTest, CreateFullscreenWindow) {
- std::unique_ptr<WindowOwner> window_owner = CreateToplevelTestWindow();
- WmWindow* window = window_owner->window();
- window->SetFullscreen(true);
- WmWindow* root_window = ShellPort::Get()->GetPrimaryRootWindow();
- EXPECT_EQ(root_window->GetBounds(), window->GetBounds());
+ std::unique_ptr<aura::Window> window = CreateTestWindow();
+ ::wm::SetWindowFullscreen(window.get(), true);
+ aura::Window* root_window = Shell::GetPrimaryRootWindow();
+ EXPECT_EQ(root_window->bounds(), window->bounds());
}
-using TopLevelWindowFactoryWmTest = mus::WmTestBase;
+using TopLevelWindowFactoryWmTest = test::AshTestBase;
TEST_F(TopLevelWindowFactoryWmTest, IsWindowShownInCorrectDisplay) {
UpdateDisplay("400x400,400x400");
EXPECT_NE(GetPrimaryDisplay().id(), GetSecondaryDisplay().id());
+ mus::WindowManager* window_manager =
+ ash_test_helper()->window_manager_app()->window_manager();
+
std::unique_ptr<aura::Window> window_primary_display(
- CreateFullscreenTestWindow(GetPrimaryDisplay().id()));
+ CreateFullscreenTestWindow(window_manager, GetPrimaryDisplay().id()));
std::unique_ptr<aura::Window> window_secondary_display(
- CreateFullscreenTestWindow(GetSecondaryDisplay().id()));
+ CreateFullscreenTestWindow(window_manager, GetSecondaryDisplay().id()));
EXPECT_EQ(GetPrimaryDisplay().id(),
GetDisplayId(window_primary_display.get()));
@@ -69,4 +92,27 @@ TEST_F(TopLevelWindowFactoryAshTest, TopLevelNotShownOnCreate) {
EXPECT_FALSE(window->IsVisible());
}
+TEST_F(TopLevelWindowFactoryAshTest, CreateTopLevelWindow) {
+ const gfx::Rect bounds(1, 2, 124, 345);
+ std::map<std::string, std::vector<uint8_t>> properties;
+ properties[ui::mojom::WindowManager::kBounds_InitProperty] =
+ mojo::ConvertTo<std::vector<uint8_t>>(bounds);
+ properties[ui::mojom::WindowManager::kResizeBehavior_Property] =
+ mojo::ConvertTo<std::vector<uint8_t>>(
+ static_cast<aura::PropertyConverter::PrimitiveType>(
+ ui::mojom::kResizeBehaviorCanResize |
+ ui::mojom::kResizeBehaviorCanMaximize |
+ ui::mojom::kResizeBehaviorCanMinimize));
+ mus::WindowManager* window_manager =
+ ash_test_helper()->window_manager_app()->window_manager();
+ // |window| is owned by its parent.
+ aura::Window* window = CreateAndParentTopLevelWindow(
+ window_manager, ui::mojom::WindowType::WINDOW, &properties);
+ ASSERT_TRUE(window->parent());
+ EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id());
+ EXPECT_EQ(bounds, window->bounds());
+ EXPECT_EQ(WidgetCreationType::FOR_CLIENT,
+ window->GetProperty(kWidgetCreationTypeKey));
+}
+
} // namespace ash
« no previous file with comments | « ash/mus/test/wm_test_base.cc ('k') | ash/test/ash_test_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698