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

Unified Diff: components/exo/shell_surface_unittest.cc

Issue 2396883003: exo: Fix dragging edge cases (Closed)
Patch Set: Fix unit tests Created 4 years, 2 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
Index: components/exo/shell_surface_unittest.cc
diff --git a/components/exo/shell_surface_unittest.cc b/components/exo/shell_surface_unittest.cc
index 38d221fc4ca330f38b3a640c5728f78e28a0752d..e34bfa4e63d17cc136e4f8a7aa725459454cabd3 100644
--- a/components/exo/shell_surface_unittest.cc
+++ b/components/exo/shell_surface_unittest.cc
@@ -50,8 +50,10 @@ TEST_F(ShellSurfaceTest, AcknowledgeConfigure) {
gfx::Size buffer_size(32, 32);
std::unique_ptr<Buffer> buffer(
new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size)));
+ const Display display;
std::unique_ptr<Surface> surface(new Surface);
- std::unique_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get()));
+ std::unique_ptr<ShellSurface> shell_surface(
+ new ShellSurface(display, surface.get()));
surface->Attach(buffer.get());
surface->Commit();
@@ -85,9 +87,10 @@ TEST_F(ShellSurfaceTest, SetParent) {
gfx::Size buffer_size(256, 256);
std::unique_ptr<Buffer> parent_buffer(
new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size)));
+ const Display display;
std::unique_ptr<Surface> parent_surface(new Surface);
std::unique_ptr<ShellSurface> parent_shell_surface(
- new ShellSurface(parent_surface.get()));
+ new ShellSurface(display, parent_surface.get()));
parent_surface->Attach(parent_buffer.get());
parent_surface->Commit();
@@ -95,7 +98,8 @@ TEST_F(ShellSurfaceTest, SetParent) {
std::unique_ptr<Buffer> buffer(
new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size)));
std::unique_ptr<Surface> surface(new Surface);
- std::unique_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get()));
+ std::unique_ptr<ShellSurface> shell_surface(
+ new ShellSurface(display, surface.get()));
shell_surface->SetParent(parent_shell_surface.get());
surface->Attach(buffer.get());
@@ -109,8 +113,10 @@ TEST_F(ShellSurfaceTest, Maximize) {
gfx::Size buffer_size(256, 256);
std::unique_ptr<Buffer> buffer(
new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size)));
+ const Display display;
std::unique_ptr<Surface> surface(new Surface);
- std::unique_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get()));
+ std::unique_ptr<ShellSurface> shell_surface(
+ new ShellSurface(display, surface.get()));
surface->Attach(buffer.get());
shell_surface->Maximize();
@@ -123,8 +129,10 @@ TEST_F(ShellSurfaceTest, Minimize) {
gfx::Size buffer_size(256, 256);
std::unique_ptr<Buffer> buffer(
new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size)));
+ const Display display;
std::unique_ptr<Surface> surface(new Surface);
- std::unique_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get()));
+ std::unique_ptr<ShellSurface> shell_surface(
+ new ShellSurface(display, surface.get()));
surface->Attach(buffer.get());
surface->Commit();
@@ -136,8 +144,10 @@ TEST_F(ShellSurfaceTest, Restore) {
gfx::Size buffer_size(256, 256);
std::unique_ptr<Buffer> buffer(
new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size)));
+ const Display display;
std::unique_ptr<Surface> surface(new Surface);
- std::unique_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get()));
+ std::unique_ptr<ShellSurface> shell_surface(
+ new ShellSurface(display, surface.get()));
surface->Attach(buffer.get());
surface->Commit();
@@ -153,8 +163,10 @@ TEST_F(ShellSurfaceTest, SetFullscreen) {
gfx::Size buffer_size(256, 256);
std::unique_ptr<Buffer> buffer(
new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size)));
+ const Display display;
std::unique_ptr<Surface> surface(new Surface);
- std::unique_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get()));
+ std::unique_ptr<ShellSurface> shell_surface(
+ new ShellSurface(display, surface.get()));
shell_surface->SetFullscreen(true);
surface->Attach(buffer.get());
@@ -167,8 +179,10 @@ TEST_F(ShellSurfaceTest, SetPinned) {
gfx::Size buffer_size(256, 256);
std::unique_ptr<Buffer> buffer(
new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size)));
+ const Display display;
std::unique_ptr<Surface> surface(new Surface);
- std::unique_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get()));
+ std::unique_ptr<ShellSurface> shell_surface(
+ new ShellSurface(display, surface.get()));
shell_surface->SetPinned(true, /* trusted */ true);
EXPECT_TRUE(
@@ -192,16 +206,20 @@ TEST_F(ShellSurfaceTest, SetPinned) {
}
TEST_F(ShellSurfaceTest, SetTitle) {
+ const Display display;
std::unique_ptr<Surface> surface(new Surface);
- std::unique_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get()));
+ std::unique_ptr<ShellSurface> shell_surface(
+ new ShellSurface(display, surface.get()));
shell_surface->SetTitle(base::string16(base::ASCIIToUTF16("test")));
surface->Commit();
}
TEST_F(ShellSurfaceTest, SetApplicationId) {
+ const Display display;
std::unique_ptr<Surface> surface(new Surface);
- std::unique_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get()));
+ std::unique_ptr<ShellSurface> shell_surface(
+ new ShellSurface(display, surface.get()));
surface->Commit();
EXPECT_EQ("", ShellSurface::GetApplicationId(
@@ -212,8 +230,10 @@ TEST_F(ShellSurfaceTest, SetApplicationId) {
}
TEST_F(ShellSurfaceTest, Move) {
+ const Display display;
std::unique_ptr<Surface> surface(new Surface);
- std::unique_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get()));
+ std::unique_ptr<ShellSurface> shell_surface(
+ new ShellSurface(display, surface.get()));
// Map shell surface.
surface->Commit();
@@ -226,8 +246,10 @@ TEST_F(ShellSurfaceTest, Move) {
}
TEST_F(ShellSurfaceTest, Resize) {
+ const Display display;
std::unique_ptr<Surface> surface(new Surface);
- std::unique_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get()));
+ std::unique_ptr<ShellSurface> shell_surface(
+ new ShellSurface(display, surface.get()));
// Map shell surface.
surface->Commit();
@@ -243,8 +265,10 @@ TEST_F(ShellSurfaceTest, SetGeometry) {
gfx::Size buffer_size(64, 64);
std::unique_ptr<Buffer> buffer(
new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size)));
+ const Display display;
std::unique_ptr<Surface> surface(new Surface);
- std::unique_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get()));
+ std::unique_ptr<ShellSurface> shell_surface(
+ new ShellSurface(display, surface.get()));
gfx::Rect geometry(16, 16, 32, 32);
shell_surface->SetGeometry(geometry);
@@ -262,8 +286,10 @@ TEST_F(ShellSurfaceTest, SetScale) {
gfx::Size buffer_size(64, 64);
std::unique_ptr<Buffer> buffer(
new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size)));
+ const Display display;
std::unique_ptr<Surface> surface(new Surface);
- std::unique_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get()));
+ std::unique_ptr<ShellSurface> shell_surface(
+ new ShellSurface(display, surface.get()));
double scale = 1.5;
shell_surface->SetScale(scale);
@@ -280,8 +306,10 @@ TEST_F(ShellSurfaceTest, SetTopInset) {
gfx::Size buffer_size(64, 64);
std::unique_ptr<Buffer> buffer(
new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size)));
+ const Display display;
std::unique_ptr<Surface> surface(new Surface);
- std::unique_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get()));
+ std::unique_ptr<ShellSurface> shell_surface(
+ new ShellSurface(display, surface.get()));
surface->Attach(buffer.get());
surface->Commit();
@@ -300,8 +328,10 @@ void Close(int* close_call_count) {
}
TEST_F(ShellSurfaceTest, CloseCallback) {
+ const Display display;
std::unique_ptr<Surface> surface(new Surface);
- std::unique_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get()));
+ std::unique_ptr<ShellSurface> shell_surface(
+ new ShellSurface(display, surface.get()));
int close_call_count = 0;
shell_surface->set_close_callback(
@@ -323,8 +353,10 @@ void DestroyShellSurface(std::unique_ptr<ShellSurface>* shell_surface) {
}
TEST_F(ShellSurfaceTest, SurfaceDestroyedCallback) {
+ const Display display;
std::unique_ptr<Surface> surface(new Surface);
- std::unique_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get()));
+ std::unique_ptr<ShellSurface> shell_surface(
+ new ShellSurface(display, surface.get()));
shell_surface->set_surface_destroyed_callback(
base::Bind(&DestroyShellSurface, base::Unretained(&shell_surface)));
@@ -352,8 +384,10 @@ uint32_t Configure(gfx::Size* suggested_size,
}
TEST_F(ShellSurfaceTest, ConfigureCallback) {
+ const Display display;
std::unique_ptr<Surface> surface(new Surface);
- std::unique_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get()));
+ std::unique_ptr<ShellSurface> shell_surface(
+ new ShellSurface(display, surface.get()));
gfx::Size suggested_size;
ash::wm::WindowStateType has_state_type = ash::wm::WINDOW_STATE_TYPE_NORMAL;
@@ -397,9 +431,10 @@ TEST_F(ShellSurfaceTest, ConfigureCallback) {
}
TEST_F(ShellSurfaceTest, ModalWindow) {
+ Display display;
std::unique_ptr<Surface> surface(new Surface);
std::unique_ptr<ShellSurface> shell_surface(
- new ShellSurface(surface.get(), nullptr, gfx::Rect(), true,
+ new ShellSurface(display, surface.get(), nullptr, gfx::Rect(), true,
ash::kShellWindowId_SystemModalContainer));
gfx::Size desktop_size(640, 480);
std::unique_ptr<Buffer> desktop_buffer(
@@ -411,14 +446,13 @@ TEST_F(ShellSurfaceTest, ModalWindow) {
EXPECT_FALSE(ash::WmShell::Get()->IsSystemModalWindowOpen());
// Creating a surface without input region should not make it modal.
- std::unique_ptr<Display> display(new Display);
- std::unique_ptr<Surface> child = display->CreateSurface();
+ std::unique_ptr<Surface> child = display.CreateSurface();
gfx::Size buffer_size(128, 128);
std::unique_ptr<Buffer> child_buffer(
new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size)));
child->Attach(child_buffer.get());
std::unique_ptr<SubSurface> sub_surface(
- display->CreateSubSurface(child.get(), surface.get()));
+ display.CreateSubSurface(child.get(), surface.get()));
surface->SetSubSurfacePosition(child.get(), gfx::Point(10, 10));
child->Commit();
surface->Commit();
@@ -445,9 +479,10 @@ TEST_F(ShellSurfaceTest, ModalWindow) {
}
TEST_F(ShellSurfaceTest, Shadow) {
+ Display display;
std::unique_ptr<Surface> surface(new Surface);
std::unique_ptr<ShellSurface> shell_surface(
- new ShellSurface(surface.get(), nullptr, gfx::Rect(), true,
+ new ShellSurface(display, surface.get(), nullptr, gfx::Rect(), true,
ash::kShellWindowId_DefaultContainer));
surface->Commit();
@@ -458,16 +493,14 @@ TEST_F(ShellSurfaceTest, Shadow) {
ASSERT_TRUE(shadow);
EXPECT_FALSE(shadow->layer()->visible());
- std::unique_ptr<Display> display(new Display);
-
// 2) Just creating a sub surface won't create a shadow.
- std::unique_ptr<Surface> child = display->CreateSurface();
+ std::unique_ptr<Surface> child = display.CreateSurface();
gfx::Size buffer_size(128, 128);
std::unique_ptr<Buffer> child_buffer(
new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size)));
child->Attach(child_buffer.get());
std::unique_ptr<SubSurface> sub_surface(
- display->CreateSubSurface(child.get(), surface.get()));
+ display.CreateSubSurface(child.get(), surface.get()));
surface->Commit();
EXPECT_FALSE(shadow->layer()->visible());
@@ -509,11 +542,12 @@ TEST_F(ShellSurfaceTest, Shadow) {
}
TEST_F(ShellSurfaceTest, ShadowWithStateChange) {
+ const Display display;
std::unique_ptr<Surface> surface(new Surface);
// Set the bounds to disable auto managed mode.
std::unique_ptr<ShellSurface> shell_surface(
- new ShellSurface(surface.get(), nullptr, gfx::Rect(640, 480), true,
- ash::kShellWindowId_DefaultContainer));
+ new ShellSurface(display, surface.get(), nullptr, gfx::Rect(640, 480),
+ true, ash::kShellWindowId_DefaultContainer));
// Postion the widget at 10,10 so that we get non zero offset.
const gfx::Size content_size(100, 100);
@@ -567,11 +601,12 @@ TEST_F(ShellSurfaceTest, ShadowWithStateChange) {
}
TEST_F(ShellSurfaceTest, ShadowWithTransform) {
+ const Display display;
std::unique_ptr<Surface> surface(new Surface);
// Set the bounds to disable auto managed mode.
std::unique_ptr<ShellSurface> shell_surface(
- new ShellSurface(surface.get(), nullptr, gfx::Rect(640, 400), true,
- ash::kShellWindowId_DefaultContainer));
+ new ShellSurface(display, surface.get(), nullptr, gfx::Rect(640, 400),
+ true, ash::kShellWindowId_DefaultContainer));
// Postion the widget at 10,10 so that we get non zero offset.
const gfx::Size content_size(100, 100);
@@ -596,10 +631,11 @@ TEST_F(ShellSurfaceTest, ShadowWithTransform) {
}
TEST_F(ShellSurfaceTest, ShadowStartMaximized) {
+ const Display display;
std::unique_ptr<Surface> surface(new Surface);
std::unique_ptr<ShellSurface> shell_surface(
- new ShellSurface(surface.get(), nullptr, gfx::Rect(640, 480), true,
- ash::kShellWindowId_DefaultContainer));
+ new ShellSurface(display, surface.get(), nullptr, gfx::Rect(640, 480),
+ true, ash::kShellWindowId_DefaultContainer));
shell_surface->Maximize();
views::Widget* widget = shell_surface->GetWidget();
aura::Window* window = widget->GetNativeWindow();
@@ -629,8 +665,10 @@ TEST_F(ShellSurfaceTest, ToggleFullscreen) {
gfx::Size buffer_size(256, 256);
std::unique_ptr<Buffer> buffer(
new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size)));
+ const Display display;
std::unique_ptr<Surface> surface(new Surface);
- std::unique_ptr<ShellSurface> shell_surface(new ShellSurface(surface.get()));
+ std::unique_ptr<ShellSurface> shell_surface(
+ new ShellSurface(display, surface.get()));
surface->Attach(buffer.get());
surface->Commit();
@@ -664,10 +702,11 @@ TEST_F(ShellSurfaceTest, ImmersiveFullscreenBackground) {
gfx::Size buffer_size(256, 256);
std::unique_ptr<Buffer> buffer(
new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size)));
+ const Display display;
std::unique_ptr<Surface> surface(new Surface);
std::unique_ptr<ShellSurface> shell_surface(
- new ShellSurface(surface.get(), nullptr, gfx::Rect(640, 480), true,
- ash::kShellWindowId_DefaultContainer));
+ new ShellSurface(display, surface.get(), nullptr, gfx::Rect(640, 480),
+ true, ash::kShellWindowId_DefaultContainer));
surface->Attach(buffer.get());
@@ -699,9 +738,10 @@ TEST_F(ShellSurfaceTest, ImmersiveFullscreenBackground) {
TEST_F(ShellSurfaceTest, SpokenFeedbackFullscreenBackground) {
gfx::Size buffer_size(256, 256);
Buffer buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size));
+ const Display display;
Surface surface;
- ShellSurface shell_surface(&surface, nullptr, gfx::Rect(640, 480), true,
- ash::kShellWindowId_DefaultContainer);
+ ShellSurface shell_surface(display, &surface, nullptr, gfx::Rect(640, 480),
+ true, ash::kShellWindowId_DefaultContainer);
surface.Attach(&buffer);
@@ -746,8 +786,8 @@ TEST_F(ShellSurfaceTest, SpokenFeedbackFullscreenBackground) {
// Create a new surface
Buffer buffer2(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size));
Surface surface2;
- ShellSurface shell_surface2(&surface2, nullptr, gfx::Rect(640, 480), true,
- ash::kShellWindowId_DefaultContainer);
+ ShellSurface shell_surface2(display, &surface2, nullptr, gfx::Rect(640, 480),
+ true, ash::kShellWindowId_DefaultContainer);
surface2.Attach(&buffer2);
shell_surface2.SetRectangularShadow(shadow_bounds);
surface2.Commit();

Powered by Google App Engine
This is Rietveld 408576698