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

Unified Diff: ui/aura/mus/window_tree_client_unittest.cc

Issue 2780043002: Aura-Mus: Allocate a LocalSurfaceId on size change (Closed)
Patch Set: Cleanup Created 3 years, 9 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 | « ui/aura/mus/window_tree_client.cc ('k') | ui/aura/test/mus/test_window_tree.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/aura/mus/window_tree_client_unittest.cc
diff --git a/ui/aura/mus/window_tree_client_unittest.cc b/ui/aura/mus/window_tree_client_unittest.cc
index 9a1d141131dd2e34967dcdbc53ec4b203e342fa4..fbfcb94487adfe6c7a99ae05bd163d5954415e64 100644
--- a/ui/aura/mus/window_tree_client_unittest.cc
+++ b/ui/aura/mus/window_tree_client_unittest.cc
@@ -155,6 +155,74 @@ TEST_F(WindowTreeClientWmTest, SetBoundsFailed) {
EXPECT_EQ(original_bounds, window.bounds());
}
+// Verifies bounds and the cc::LocalSurfaceId associated with the bounds are
+// reverted if the server replied that the change failed.
+TEST_F(WindowTreeClientWmTest, SetBoundsFailedLocalSurfaceId) {
+ Window window(nullptr);
+ // TOP_LEVEL_IN_WM and EMBED_IN_OWNER windows allocate cc::LocalSurfaceIds
+ // when their sizes change.
+ window.SetProperty(aura::client::kEmbedType,
+ aura::client::WindowEmbedType::EMBED_IN_OWNER);
+ window.Init(ui::LAYER_NOT_DRAWN);
+
+ const gfx::Rect original_bounds(window.bounds());
+ const gfx::Rect new_bounds(gfx::Rect(0, 0, 100, 100));
+ ASSERT_NE(new_bounds, window.bounds());
+ window.SetBounds(new_bounds);
+ EXPECT_EQ(new_bounds, window.bounds());
+ WindowMus* window_mus = WindowMus::Get(&window);
+ ASSERT_NE(nullptr, window_mus);
+ EXPECT_TRUE(window_mus->GetLocalSurfaceId().is_valid());
+
+ // Reverting the change should also revert the cc::LocalSurfaceId.
+ ASSERT_TRUE(window_tree()->AckSingleChangeOfType(WindowTreeChangeType::BOUNDS,
+ false));
+ EXPECT_EQ(original_bounds, window.bounds());
+ EXPECT_FALSE(window_mus->GetLocalSurfaceId().is_valid());
+}
+
+// Verifies that the cc::LocalSurfaceId generated by an embedder changes when
+// the size changes, but not when the position changes.
+TEST_F(WindowTreeClientWmTest, SetBoundsLocalSurfaceIdChanges) {
+ ASSERT_EQ(base::nullopt, window_tree()->last_local_surface_id());
+ Window window(nullptr);
+ // TOP_LEVEL_IN_WM and EMBED_IN_OWNER windows allocate cc::LocalSurfaceIds
+ // when their sizes change.
+ window.SetProperty(aura::client::kEmbedType,
+ aura::client::WindowEmbedType::EMBED_IN_OWNER);
+ window.Init(ui::LAYER_NOT_DRAWN);
+
+ // Resize the window and verify that we've allocated a cc::LocalSurfaceId.
+ const gfx::Rect new_bounds(0, 0, 100, 100);
+ ASSERT_NE(new_bounds, window.bounds());
+ window.SetBounds(new_bounds);
+ EXPECT_EQ(new_bounds, window.bounds());
+ base::Optional<cc::LocalSurfaceId> last_local_surface_id =
+ window_tree()->last_local_surface_id();
+ ASSERT_NE(base::nullopt, last_local_surface_id);
+
+ // Resize the window again and verify that the cc::LocalSurfaceId has changed.
+ const gfx::Rect new_bounds2(0, 0, 100, 102);
+ ASSERT_NE(new_bounds2, window.bounds());
+ window.SetBounds(new_bounds2);
+ EXPECT_EQ(new_bounds2, window.bounds());
+ base::Optional<cc::LocalSurfaceId> last_local_surface_id2 =
+ window_tree()->last_local_surface_id();
+ ASSERT_NE(base::nullopt, last_local_surface_id2);
+ EXPECT_NE(last_local_surface_id2, last_local_surface_id);
+
+ // Moving the window but not changing the size should not allocate a new
+ // cc::LocalSurfaceId.
+ const gfx::Rect new_bounds3(1337, 7331, 100, 102);
+ ASSERT_NE(new_bounds3, window.bounds());
+ window.SetBounds(new_bounds3);
+ EXPECT_EQ(new_bounds3, window.bounds());
+ base::Optional<cc::LocalSurfaceId> last_local_surface_id3 =
+ window_tree()->last_local_surface_id();
+ ASSERT_NE(base::nullopt, last_local_surface_id3);
+ EXPECT_EQ(last_local_surface_id2, last_local_surface_id3);
+}
+
// Verifies a new window from the server doesn't result in attempting to add
// the window back to the server.
TEST_F(WindowTreeClientWmTest, AddFromServerDoesntAddAgain) {
@@ -266,6 +334,8 @@ TEST_F(WindowTreeClientWmTest, FocusFromServer) {
// Simulates a bounds change, and while the bounds change is in flight the
// server replies with a new bounds and the original bounds change fails.
+// The server bounds change takes hold along with the associated
+// cc::LocalSurfaceId.
TEST_F(WindowTreeClientWmTest, SetBoundsFailedWithPendingChange) {
const gfx::Rect original_bounds(root_window()->bounds());
const gfx::Rect new_bounds(gfx::Rect(0, 0, 100, 100));
@@ -275,24 +345,33 @@ TEST_F(WindowTreeClientWmTest, SetBoundsFailedWithPendingChange) {
// Simulate the server responding with a bounds change.
const gfx::Rect server_changed_bounds(gfx::Rect(0, 0, 101, 102));
+ const cc::LocalSurfaceId server_changed_local_surface_id(
+ 1, base::UnguessableToken::Create());
window_tree_client()->OnWindowBoundsChanged(
server_id(root_window()), original_bounds, server_changed_bounds,
- base::nullopt);
+ server_changed_local_surface_id);
+
+ WindowMus* root_window_mus = WindowMus::Get(root_window());
+ ASSERT_NE(nullptr, root_window_mus);
// This shouldn't trigger the bounds changing yet.
EXPECT_EQ(new_bounds, root_window()->bounds());
+ EXPECT_FALSE(root_window_mus->GetLocalSurfaceId().is_valid());
// Tell the client the change failed, which should trigger failing to the
// most recent bounds from server.
ASSERT_TRUE(window_tree()->AckSingleChangeOfType(WindowTreeChangeType::BOUNDS,
false));
EXPECT_EQ(server_changed_bounds, root_window()->bounds());
+ EXPECT_EQ(server_changed_local_surface_id,
+ root_window_mus->GetLocalSurfaceId());
// Simulate server changing back to original bounds. Should take immediately.
window_tree_client()->OnWindowBoundsChanged(server_id(root_window()),
server_changed_bounds,
original_bounds, base::nullopt);
EXPECT_EQ(original_bounds, root_window()->bounds());
+ EXPECT_FALSE(root_window_mus->GetLocalSurfaceId().is_valid());
}
TEST_F(WindowTreeClientWmTest, TwoInFlightBoundsChangesBothCanceled) {
« no previous file with comments | « ui/aura/mus/window_tree_client.cc ('k') | ui/aura/test/mus/test_window_tree.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698