| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium OS 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 <string> | 6 #include <string> |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include <gflags/gflags.h> | 9 #include <gflags/gflags.h> |
| 10 #include <gtest/gtest.h> | 10 #include <gtest/gtest.h> |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 EXPECT_TRUE(win.FetchAndApplyWindowType()); | 70 EXPECT_TRUE(win.FetchAndApplyWindowType()); |
| 71 EXPECT_EQ(chromeos::WM_IPC_WINDOW_CHROME_TOPLEVEL, win.type()); | 71 EXPECT_EQ(chromeos::WM_IPC_WINDOW_CHROME_TOPLEVEL, win.type()); |
| 72 | 72 |
| 73 ASSERT_TRUE(wm_->wm_ipc()->SetWindowType( | 73 ASSERT_TRUE(wm_->wm_ipc()->SetWindowType( |
| 74 xid, chromeos::WM_IPC_WINDOW_CHROME_INFO_BUBBLE, NULL)); | 74 xid, chromeos::WM_IPC_WINDOW_CHROME_INFO_BUBBLE, NULL)); |
| 75 EXPECT_TRUE(win.FetchAndApplyWindowType()); | 75 EXPECT_TRUE(win.FetchAndApplyWindowType()); |
| 76 EXPECT_EQ(chromeos::WM_IPC_WINDOW_CHROME_INFO_BUBBLE, win.type()); | 76 EXPECT_EQ(chromeos::WM_IPC_WINDOW_CHROME_INFO_BUBBLE, win.type()); |
| 77 } | 77 } |
| 78 | 78 |
| 79 TEST_F(WindowTest, ChangeClient) { | 79 TEST_F(WindowTest, ChangeClient) { |
| 80 XWindow xid = CreateBasicWindow(10, 20, 30, 40); | 80 XWindow xid = CreateBasicWindow(Rect(10, 20, 30, 40)); |
| 81 MockXConnection::WindowInfo* info = xconn_->GetWindowInfoOrDie(xid); | 81 MockXConnection::WindowInfo* info = xconn_->GetWindowInfoOrDie(xid); |
| 82 XConnection::WindowGeometry geometry; | 82 XConnection::WindowGeometry geometry; |
| 83 ASSERT_TRUE(xconn_->GetWindowGeometry(xid, &geometry)); | 83 ASSERT_TRUE(xconn_->GetWindowGeometry(xid, &geometry)); |
| 84 Window window(wm_.get(), xid, false, geometry); | 84 Window window(wm_.get(), xid, false, geometry); |
| 85 | 85 |
| 86 // Make sure that the window's initial attributes are loaded correctly. | 86 // Make sure that the window's initial attributes are loaded correctly. |
| 87 EXPECT_EQ(xid, window.xid()); | 87 EXPECT_EQ(xid, window.xid()); |
| 88 EXPECT_EQ(10, window.client_x()); | 88 EXPECT_EQ(10, window.client_x()); |
| 89 EXPECT_EQ(20, window.client_y()); | 89 EXPECT_EQ(20, window.client_y()); |
| 90 EXPECT_EQ(30, window.client_width()); | 90 EXPECT_EQ(30, window.client_width()); |
| 91 EXPECT_EQ(40, window.client_height()); | 91 EXPECT_EQ(40, window.client_height()); |
| 92 EXPECT_EQ(false, window.mapped()); | 92 EXPECT_EQ(false, window.mapped()); |
| 93 | 93 |
| 94 EXPECT_TRUE(window.MapClient()); | 94 EXPECT_TRUE(window.MapClient()); |
| 95 EXPECT_TRUE(info->mapped); | 95 EXPECT_TRUE(info->mapped); |
| 96 | 96 |
| 97 // Move the window. | 97 // Move the window. |
| 98 EXPECT_TRUE(window.MoveClient(100, 200)); | 98 EXPECT_TRUE(window.MoveClient(100, 200)); |
| 99 EXPECT_EQ(100, info->bounds.x); | 99 EXPECT_EQ(100, info->bounds.x); |
| 100 EXPECT_EQ(200, info->bounds.y); | 100 EXPECT_EQ(200, info->bounds.y); |
| 101 EXPECT_EQ(100, window.client_x()); | 101 EXPECT_EQ(100, window.client_x()); |
| 102 EXPECT_EQ(200, window.client_y()); | 102 EXPECT_EQ(200, window.client_y()); |
| 103 | 103 |
| 104 // Resize the window. | 104 // Resize the window. |
| 105 EXPECT_TRUE(window.ResizeClient(300, 400, GRAVITY_NORTHWEST)); | 105 EXPECT_TRUE(window.Resize(Size(300, 400), GRAVITY_NORTHWEST)); |
| 106 EXPECT_EQ(300, info->bounds.width); | 106 EXPECT_EQ(300, info->bounds.width); |
| 107 EXPECT_EQ(400, info->bounds.height); | 107 EXPECT_EQ(400, info->bounds.height); |
| 108 EXPECT_EQ(300, window.client_width()); | 108 EXPECT_EQ(300, window.client_width()); |
| 109 EXPECT_EQ(400, window.client_height()); | 109 EXPECT_EQ(400, window.client_height()); |
| 110 | |
| 111 // We need to be able to update windows' local geometry variables in | |
| 112 // response to ConfigureNotify events to be able to handle | |
| 113 // override-redirect windows, so make sure that that works correctly. | |
| 114 window.SaveClientPosition(50, 60); | |
| 115 window.SaveClientSize(70, 80); | |
| 116 EXPECT_EQ(50, window.client_x()); | |
| 117 EXPECT_EQ(60, window.client_y()); | |
| 118 EXPECT_EQ(70, window.client_width()); | |
| 119 EXPECT_EQ(80, window.client_height()); | |
| 120 } | 110 } |
| 121 | 111 |
| 122 TEST_F(WindowTest, ChangeComposited) { | 112 TEST_F(WindowTest, ChangeComposited) { |
| 123 XWindow xid = CreateBasicWindow(10, 20, 30, 40); | 113 XWindow xid = CreateBasicWindow(Rect(10, 20, 30, 40)); |
| 124 XConnection::WindowGeometry geometry; | 114 XConnection::WindowGeometry geometry; |
| 125 ASSERT_TRUE(xconn_->GetWindowGeometry(xid, &geometry)); | 115 ASSERT_TRUE(xconn_->GetWindowGeometry(xid, &geometry)); |
| 126 Window window(wm_.get(), xid, false, geometry); | 116 Window window(wm_.get(), xid, false, geometry); |
| 127 xconn_->MapWindow(xid); | 117 xconn_->MapWindow(xid); |
| 128 window.HandleMapNotify(); | 118 window.HandleMapNotify(); |
| 129 | 119 |
| 130 MockCompositor::TexturePixmapActor* actor = GetMockActorForWindow(&window); | 120 MockCompositor::TexturePixmapActor* actor = GetMockActorForWindow(&window); |
| 131 | 121 |
| 132 // Initially, we should place the composited window at the same location | 122 // Initially, we should place the composited window at the same location |
| 133 // as the client window. | 123 // as the client window. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 Window win(wm_.get(), xid, false, geometry); | 157 Window win(wm_.get(), xid, false, geometry); |
| 168 EXPECT_EQ(owner_xid, win.transient_for_xid()); | 158 EXPECT_EQ(owner_xid, win.transient_for_xid()); |
| 169 | 159 |
| 170 XWindow new_owner_xid = 5678; | 160 XWindow new_owner_xid = 5678; |
| 171 info->transient_for = new_owner_xid; | 161 info->transient_for = new_owner_xid; |
| 172 EXPECT_TRUE(win.FetchAndApplyTransientHint()); | 162 EXPECT_TRUE(win.FetchAndApplyTransientHint()); |
| 173 EXPECT_EQ(new_owner_xid, win.transient_for_xid()); | 163 EXPECT_EQ(new_owner_xid, win.transient_for_xid()); |
| 174 } | 164 } |
| 175 | 165 |
| 176 TEST_F(WindowTest, GetMaxSize) { | 166 TEST_F(WindowTest, GetMaxSize) { |
| 177 XWindow xid = CreateBasicWindow(10, 20, 30, 40); | 167 XWindow xid = CreateBasicWindow(Rect(10, 20, 30, 40)); |
| 178 | 168 |
| 179 MockXConnection::WindowInfo* info = xconn_->GetWindowInfoOrDie(xid); | 169 MockXConnection::WindowInfo* info = xconn_->GetWindowInfoOrDie(xid); |
| 180 info->size_hints.min_size.reset(400, 300); | 170 info->size_hints.min_size.reset(400, 300); |
| 181 info->size_hints.max_size.reset(800, 600); | 171 info->size_hints.max_size.reset(800, 600); |
| 182 info->size_hints.size_increment.reset(10, 5); | 172 info->size_hints.size_increment.reset(10, 5); |
| 183 info->size_hints.base_size.reset(40, 30); | 173 info->size_hints.base_size.reset(40, 30); |
| 184 | 174 |
| 185 XConnection::WindowGeometry geometry; | 175 XConnection::WindowGeometry geometry; |
| 186 ASSERT_TRUE(xconn_->GetWindowGeometry(xid, &geometry)); | 176 ASSERT_TRUE(xconn_->GetWindowGeometry(xid, &geometry)); |
| 187 Window win(wm_.get(), xid, false, geometry); | 177 Window win(wm_.get(), xid, false, geometry); |
| 188 ASSERT_TRUE(win.FetchAndApplySizeHints()); | 178 ASSERT_TRUE(win.FetchAndApplySizeHints()); |
| 189 int width = 0, height = 0; | 179 Size size; |
| 190 | 180 |
| 191 // We should get the minimum size if we request a size smaller than it. | 181 // We should get the minimum size if we request a size smaller than it. |
| 192 win.GetMaxSize(300, 200, &width, &height); | 182 win.GetMaxSize(Size(300, 200), &size); |
| 193 EXPECT_EQ(400, width); | 183 EXPECT_EQ(Size(400, 300), size); |
| 194 EXPECT_EQ(300, height); | |
| 195 | 184 |
| 196 // And the maximum size if we request one larger than it. | 185 // And the maximum size if we request one larger than it. |
| 197 win.GetMaxSize(1000, 800, &width, &height); | 186 win.GetMaxSize(Size(1000, 800), &size); |
| 198 EXPECT_EQ(800, width); | 187 EXPECT_EQ(Size(800, 600), size); |
| 199 EXPECT_EQ(600, height); | |
| 200 | 188 |
| 201 // Test that the size increment hints are honored when we request a size | 189 // Test that the size increment hints are honored when we request a size |
| 202 // that's not equal to the base size plus some multiple of the size | 190 // that's not equal to the base size plus some multiple of the size |
| 203 // increments. | 191 // increments. |
| 204 win.GetMaxSize(609, 409, &width, &height); | 192 win.GetMaxSize(Size(609, 409), &size); |
| 205 EXPECT_EQ(600, width); | 193 EXPECT_EQ(Size(600, 405), size); |
| 206 EXPECT_EQ(405, height); | |
| 207 } | 194 } |
| 208 | 195 |
| 209 // Test WM_DELETE_WINDOW and WM_TAKE_FOCUS from ICCCM's WM_PROTOCOLS. | 196 // Test WM_DELETE_WINDOW and WM_TAKE_FOCUS from ICCCM's WM_PROTOCOLS. |
| 210 TEST_F(WindowTest, WmProtocols) { | 197 TEST_F(WindowTest, WmProtocols) { |
| 211 // Create a window. | 198 // Create a window. |
| 212 XWindow xid = CreateSimpleWindow(); | 199 XWindow xid = CreateSimpleWindow(); |
| 213 MockXConnection::WindowInfo* info = xconn_->GetWindowInfoOrDie(xid); | 200 MockXConnection::WindowInfo* info = xconn_->GetWindowInfoOrDie(xid); |
| 214 | 201 |
| 215 // Set its WM_PROTOCOLS property to indicate that it supports both | 202 // Set its WM_PROTOCOLS property to indicate that it supports both |
| 216 // message types. | 203 // message types. |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 423 TEST_F(WindowTest, Shape) { | 410 TEST_F(WindowTest, Shape) { |
| 424 // Loading windows' regions is turned off by default, since it can cause | 411 // Loading windows' regions is turned off by default, since it can cause |
| 425 // a pretty big memory allocation for new windows and the compositor | 412 // a pretty big memory allocation for new windows and the compositor |
| 426 // doesn't currently even support using these regions as masks, but we | 413 // doesn't currently even support using these regions as masks, but we |
| 427 // need to enable it to test this code. | 414 // need to enable it to test this code. |
| 428 AutoReset<bool> flag_resetter(&FLAGS_load_window_shapes, true); | 415 AutoReset<bool> flag_resetter(&FLAGS_load_window_shapes, true); |
| 429 | 416 |
| 430 // Create a shaped window. | 417 // Create a shaped window. |
| 431 int width = 10; | 418 int width = 10; |
| 432 int height = 5; | 419 int height = 5; |
| 433 XWindow xid = CreateBasicWindow(10, 20, width, height); | 420 XWindow xid = CreateBasicWindow(Rect(10, 20, width, height)); |
| 434 MockXConnection::WindowInfo* info = xconn_->GetWindowInfoOrDie(xid); | 421 MockXConnection::WindowInfo* info = xconn_->GetWindowInfoOrDie(xid); |
| 435 info->shape.reset(new ByteMap(width, height)); | 422 info->shape.reset(new ByteMap(Size(width, height))); |
| 436 info->shape->Clear(0xff); | 423 info->shape->Clear(0xff); |
| 437 info->shape->SetRectangle(0, 0, 3, 3, 0x0); | 424 info->shape->SetRectangle(Rect(0, 0, 3, 3), 0x0); |
| 438 | 425 |
| 439 XConnection::WindowGeometry geometry; | 426 XConnection::WindowGeometry geometry; |
| 440 ASSERT_TRUE(xconn_->GetWindowGeometry(xid, &geometry)); | 427 ASSERT_TRUE(xconn_->GetWindowGeometry(xid, &geometry)); |
| 441 Window win(wm_.get(), xid, false, geometry); | 428 Window win(wm_.get(), xid, false, geometry); |
| 442 win.SetShadowType(Shadow::TYPE_RECTANGULAR); | 429 win.SetShadowType(Shadow::TYPE_RECTANGULAR); |
| 443 EXPECT_TRUE(info->shape_events_selected); | 430 EXPECT_TRUE(info->shape_events_selected); |
| 444 EXPECT_TRUE(win.shaped()); | 431 EXPECT_TRUE(win.shaped()); |
| 445 win.HandleMapNotify(); | 432 win.HandleMapNotify(); |
| 446 win.ShowComposited(); | 433 win.ShowComposited(); |
| 447 | 434 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 458 // Check that the shape mask got applied to the compositing actor. | 445 // Check that the shape mask got applied to the compositing actor. |
| 459 MockCompositor::TexturePixmapActor* mock_actor = GetMockActorForWindow(&win); | 446 MockCompositor::TexturePixmapActor* mock_actor = GetMockActorForWindow(&win); |
| 460 ASSERT_TRUE(mock_actor->alpha_mask_bytes() != NULL); | 447 ASSERT_TRUE(mock_actor->alpha_mask_bytes() != NULL); |
| 461 EXPECT_PRED_FORMAT3(BytesAreEqual, | 448 EXPECT_PRED_FORMAT3(BytesAreEqual, |
| 462 info->shape->bytes(), | 449 info->shape->bytes(), |
| 463 mock_actor->alpha_mask_bytes(), | 450 mock_actor->alpha_mask_bytes(), |
| 464 width * height); | 451 width * height); |
| 465 | 452 |
| 466 // Change the shape and check that the window updates its actor. | 453 // Change the shape and check that the window updates its actor. |
| 467 info->shape->Clear(0xff); | 454 info->shape->Clear(0xff); |
| 468 info->shape->SetRectangle(width - 3, height - 3, 3, 3, 0x0); | 455 info->shape->SetRectangle(Rect(width - 3, height - 3, 3, 3), 0x0); |
| 469 win.FetchAndApplyShape(); | 456 win.FetchAndApplyShape(); |
| 470 EXPECT_TRUE(win.shaped()); | 457 EXPECT_TRUE(win.shaped()); |
| 471 EXPECT_FALSE(win.shadow()->is_shown()); | 458 EXPECT_FALSE(win.shadow()->is_shown()); |
| 472 ASSERT_TRUE(mock_actor->alpha_mask_bytes() != NULL); | 459 ASSERT_TRUE(mock_actor->alpha_mask_bytes() != NULL); |
| 473 EXPECT_PRED_FORMAT3(BytesAreEqual, | 460 EXPECT_PRED_FORMAT3(BytesAreEqual, |
| 474 info->shape->bytes(), | 461 info->shape->bytes(), |
| 475 mock_actor->alpha_mask_bytes(), | 462 mock_actor->alpha_mask_bytes(), |
| 476 width * height); | 463 width * height); |
| 477 | 464 |
| 478 // Now clear the shape and make sure that the mask is removed from the | 465 // Now clear the shape and make sure that the mask is removed from the |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 510 ASSERT_TRUE(xconn_->GetWindowGeometry(xid, &geometry)); | 497 ASSERT_TRUE(xconn_->GetWindowGeometry(xid, &geometry)); |
| 511 Window win(wm_.get(), xid, false, geometry); | 498 Window win(wm_.get(), xid, false, geometry); |
| 512 EXPECT_EQ(0, info->border_width); | 499 EXPECT_EQ(0, info->border_width); |
| 513 } | 500 } |
| 514 | 501 |
| 515 // Test that we don't resize the composited window until we receive | 502 // Test that we don't resize the composited window until we receive |
| 516 // notification that the client window has been resized. Otherwise, we can | 503 // notification that the client window has been resized. Otherwise, we can |
| 517 // end up with the previous contents being scaled to fit the new size -- | 504 // end up with the previous contents being scaled to fit the new size -- |
| 518 // see http://crosbug.com/1279. | 505 // see http://crosbug.com/1279. |
| 519 TEST_F(WindowTest, DeferResizingActor) { | 506 TEST_F(WindowTest, DeferResizingActor) { |
| 520 const int orig_width = 300, orig_height = 200; | 507 const Rect kOrigBounds(0, 0, 300, 200); |
| 521 XWindow xid = CreateToplevelWindow(2, 0, 0, 0, orig_width, orig_height); | 508 XWindow xid = CreateToplevelWindow(2, 0, kOrigBounds); |
| 522 XConnection::WindowGeometry geometry; | 509 XConnection::WindowGeometry geometry; |
| 523 ASSERT_TRUE(xconn_->GetWindowGeometry(xid, &geometry)); | 510 ASSERT_TRUE(xconn_->GetWindowGeometry(xid, &geometry)); |
| 524 Window win(wm_.get(), xid, false, geometry); | 511 Window win(wm_.get(), xid, false, geometry); |
| 525 xconn_->MapWindow(xid); | 512 xconn_->MapWindow(xid); |
| 526 win.HandleMapNotify(); | 513 win.HandleMapNotify(); |
| 527 | 514 |
| 528 // Check that the actor's initial dimensions match that of the client window. | 515 // Check that the actor's initial dimensions match that of the client window. |
| 529 EXPECT_EQ(orig_width, win.actor()->GetWidth()); | 516 EXPECT_EQ(kOrigBounds.size(), win.actor()->GetBounds().size()); |
| 530 EXPECT_EQ(orig_height, win.actor()->GetHeight()); | |
| 531 | 517 |
| 532 // After resizing the client window, the actor should still still be | 518 // After resizing the client window, the actor should still still be |
| 533 // using the original dimensions. | 519 // using the original dimensions. |
| 534 const int new_width = 600, new_height = 400; | 520 const Rect kNewBounds(0, 0, 600, 400); |
| 535 win.ResizeClient(new_width, new_height, GRAVITY_NORTHWEST); | 521 win.Resize(kNewBounds.size(), GRAVITY_NORTHWEST); |
| 536 EXPECT_EQ(orig_width, win.actor()->GetWidth()); | 522 EXPECT_EQ(kOrigBounds.size(), win.actor()->GetBounds().size()); |
| 537 EXPECT_EQ(orig_height, win.actor()->GetHeight()); | |
| 538 | 523 |
| 539 // Now let the window know that we've seen a ConfigureNotify event with | 524 // Now let the window know that we've seen a ConfigureNotify event with |
| 540 // the new dimensions and check that the actor is resized. | 525 // the new dimensions and check that the actor is resized. |
| 541 win.HandleConfigureNotify(new_width, new_height); | 526 win.HandleConfigureNotify(kNewBounds, 0); |
| 542 EXPECT_EQ(new_width, win.actor()->GetWidth()); | 527 EXPECT_EQ(kNewBounds.size(), win.actor()->GetBounds().size()); |
| 543 EXPECT_EQ(new_height, win.actor()->GetHeight()); | |
| 544 } | 528 } |
| 545 | 529 |
| 546 // Test that pixmap actor and shadow sizes get updated correctly in | 530 // Test that pixmap actor and shadow sizes get updated correctly in |
| 547 // response to ConfigureNotify events. | 531 // response to ConfigureNotify events. |
| 548 TEST_F(WindowTest, UpdatePixmapAndShadowSizes) { | 532 TEST_F(WindowTest, UpdatePixmapAndShadowSizes) { |
| 549 const int orig_width = 300, orig_height = 200; | 533 const int orig_width = 300, orig_height = 200; |
| 550 XWindow xid = CreateToplevelWindow(2, 0, 0, 0, orig_width, orig_height); | 534 XWindow xid = CreateToplevelWindow(2, 0, Rect(0, 0, orig_width, orig_height)); |
| 551 MockXConnection::WindowInfo* info = xconn_->GetWindowInfoOrDie(xid); | 535 MockXConnection::WindowInfo* info = xconn_->GetWindowInfoOrDie(xid); |
| 552 XConnection::WindowGeometry geometry; | 536 XConnection::WindowGeometry geometry; |
| 553 ASSERT_TRUE(xconn_->GetWindowGeometry(xid, &geometry)); | 537 ASSERT_TRUE(xconn_->GetWindowGeometry(xid, &geometry)); |
| 554 Window win(wm_.get(), xid, false, geometry); | 538 Window win(wm_.get(), xid, false, geometry); |
| 555 win.SetShadowType(Shadow::TYPE_RECTANGULAR); | 539 win.SetShadowType(Shadow::TYPE_RECTANGULAR); |
| 556 | 540 |
| 557 // Resize the window once before it gets mapped, to make sure that we get | 541 // Resize the window once before it gets mapped, to make sure that we get |
| 558 // the updated size later after the window is mapped. | 542 // the updated size later after the window is mapped. |
| 559 const int second_width = orig_width + 10, second_height = orig_height + 10; | 543 const int second_width = orig_width + 10, second_height = orig_height + 10; |
| 560 ASSERT_TRUE(xconn_->ResizeWindow(xid, Size(second_width, second_height))); | 544 ASSERT_TRUE(xconn_->ResizeWindow(xid, Size(second_width, second_height))); |
| 561 win.HandleConfigureNotify(info->bounds.width, info->bounds.height); | 545 win.HandleConfigureNotify(info->bounds, 0); |
| 562 | 546 |
| 563 // Now map the window and check that everything starts out at the right size. | 547 // Now map the window and check that everything starts out at the right size. |
| 564 ASSERT_TRUE(xconn_->MapWindow(xid)); | 548 ASSERT_TRUE(xconn_->MapWindow(xid)); |
| 565 win.HandleMapNotify(); | 549 win.HandleMapNotify(); |
| 566 MockCompositor::TexturePixmapActor* actor = GetMockActorForWindow(&win); | 550 MockCompositor::TexturePixmapActor* actor = GetMockActorForWindow(&win); |
| 567 EXPECT_EQ(second_width, actor->GetWidth()); | 551 EXPECT_EQ(second_width, actor->GetWidth()); |
| 568 EXPECT_EQ(second_height, actor->GetHeight()); | 552 EXPECT_EQ(second_height, actor->GetHeight()); |
| 569 EXPECT_EQ(second_width, win.shadow()->width()); | 553 EXPECT_EQ(second_width, win.shadow()->width()); |
| 570 EXPECT_EQ(second_height, win.shadow()->height()); | 554 EXPECT_EQ(second_height, win.shadow()->height()); |
| 571 | 555 |
| 572 // We shouldn't reload the pixmap in response to a non-resize | 556 // We shouldn't reload the pixmap in response to a non-resize |
| 573 // ConfigureNotify event (like what we'll receive whenever the window | 557 // ConfigureNotify event (like what we'll receive whenever the window |
| 574 // gets moved). | 558 // gets moved). |
| 575 XID prev_pixmap = actor->pixmap(); | 559 XID prev_pixmap = actor->pixmap(); |
| 576 win.HandleConfigureNotify(info->bounds.width, info->bounds.height); | 560 win.HandleConfigureNotify(info->bounds, 0); |
| 577 EXPECT_EQ(prev_pixmap, actor->pixmap()); | 561 EXPECT_EQ(prev_pixmap, actor->pixmap()); |
| 578 | 562 |
| 579 // Now act as if the window gets resized two more times, but the second | 563 // Now act as if the window gets resized two more times, but the second |
| 580 // resize has already happened in the X server by the time that the | 564 // resize has already happened in the X server by the time that the |
| 581 // window manager receives the ConfigureNotify for the first resize. | 565 // window manager receives the ConfigureNotify for the first resize. |
| 582 const int third_width = second_width + 10, third_height = second_height + 10; | 566 const int third_width = second_width + 10, third_height = second_height + 10; |
| 583 const int fourth_width = third_width + 10, fourth_height = third_height + 10; | 567 const int fourth_width = third_width + 10, fourth_height = third_height + 10; |
| 584 xconn_->ResizeWindow(xid, Size(fourth_width, fourth_height)); | 568 xconn_->ResizeWindow(xid, Size(fourth_width, fourth_height)); |
| 585 win.HandleConfigureNotify(third_width, third_height); | 569 win.HandleConfigureNotify( |
| 570 Rect(info->bounds.x, info->bounds.y, third_width, third_height), 0); |
| 586 | 571 |
| 587 // We should load the pixmap now and resize the shadow to the dimensions | 572 // We should load the pixmap now and resize the shadow to the dimensions |
| 588 // from the final pixmap instead of the ones supplied in the event. | 573 // from the final pixmap instead of the ones supplied in the event. |
| 589 EXPECT_EQ(fourth_width, actor->GetWidth()); | 574 EXPECT_EQ(fourth_width, actor->GetWidth()); |
| 590 EXPECT_EQ(fourth_height, actor->GetHeight()); | 575 EXPECT_EQ(fourth_height, actor->GetHeight()); |
| 591 EXPECT_EQ(fourth_width, win.shadow()->width()); | 576 EXPECT_EQ(fourth_width, win.shadow()->width()); |
| 592 EXPECT_EQ(fourth_height, win.shadow()->height()); | 577 EXPECT_EQ(fourth_height, win.shadow()->height()); |
| 593 | 578 |
| 594 // Nothing should change after we get the second ConfigureNotify. | 579 // Nothing should change after we get the second ConfigureNotify. |
| 595 win.HandleConfigureNotify(fourth_width, fourth_height); | 580 win.HandleConfigureNotify(info->bounds, 0); |
| 596 EXPECT_EQ(fourth_width, actor->GetWidth()); | 581 EXPECT_EQ(fourth_width, actor->GetWidth()); |
| 597 EXPECT_EQ(fourth_height, actor->GetHeight()); | 582 EXPECT_EQ(fourth_height, actor->GetHeight()); |
| 598 EXPECT_EQ(fourth_width, win.shadow()->width()); | 583 EXPECT_EQ(fourth_width, win.shadow()->width()); |
| 599 EXPECT_EQ(fourth_height, win.shadow()->height()); | 584 EXPECT_EQ(fourth_height, win.shadow()->height()); |
| 600 } | 585 } |
| 601 | 586 |
| 602 // Test that we show and hide shadows under the proper conditions (note | 587 // Test that we show and hide shadows under the proper conditions (note |
| 603 // that a portion of this is covered by the Shape test). | 588 // that a portion of this is covered by the Shape test). |
| 604 TEST_F(WindowTest, ShadowVisibility) { | 589 TEST_F(WindowTest, ShadowVisibility) { |
| 605 XWindow xid = CreateSimpleWindow(); | 590 XWindow xid = CreateSimpleWindow(); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 638 XWindow xid = CreateSimpleWindow(); | 623 XWindow xid = CreateSimpleWindow(); |
| 639 XConnection::WindowGeometry geometry; | 624 XConnection::WindowGeometry geometry; |
| 640 ASSERT_TRUE(xconn_->GetWindowGeometry(xid, &geometry)); | 625 ASSERT_TRUE(xconn_->GetWindowGeometry(xid, &geometry)); |
| 641 Window win(wm_.get(), xid, false, geometry); | 626 Window win(wm_.get(), xid, false, geometry); |
| 642 xconn_->MapWindow(xid); | 627 xconn_->MapWindow(xid); |
| 643 win.HandleMapRequested(); | 628 win.HandleMapRequested(); |
| 644 win.HandleMapNotify(); | 629 win.HandleMapNotify(); |
| 645 MockCompositor::TexturePixmapActor* actor = GetMockActorForWindow(&win); | 630 MockCompositor::TexturePixmapActor* actor = GetMockActorForWindow(&win); |
| 646 | 631 |
| 647 EXPECT_TRUE(win.client_has_redrawn_after_last_resize_); | 632 EXPECT_TRUE(win.client_has_redrawn_after_last_resize_); |
| 648 EXPECT_EQ(geometry.bounds.width, actor->GetWidth()); | 633 EXPECT_EQ(geometry.bounds.size(), actor->GetBounds().size()); |
| 649 EXPECT_EQ(geometry.bounds.height, actor->GetHeight()); | |
| 650 | 634 |
| 651 // If the client doesn't support the sync request protocol, we should | 635 // If the client doesn't support the sync request protocol, we should |
| 652 // just pretend like it's always redrawn the window immediately after a | 636 // just pretend like it's always redrawn the window immediately after a |
| 653 // resize. | 637 // resize. |
| 654 win.ResizeClient(500, 500, GRAVITY_NORTHWEST); | 638 Size kFirstSize(500, 500); |
| 639 win.Resize(kFirstSize, GRAVITY_NORTHWEST); |
| 655 EXPECT_TRUE(win.client_has_redrawn_after_last_resize_); | 640 EXPECT_TRUE(win.client_has_redrawn_after_last_resize_); |
| 656 win.HandleConfigureNotify(500, 500); | 641 win.HandleConfigureNotify(Rect(geometry.bounds.position(), kFirstSize), 0); |
| 657 EXPECT_EQ(500, actor->GetWidth()); | 642 EXPECT_EQ(kFirstSize, actor->GetBounds().size()); |
| 658 EXPECT_EQ(500, actor->GetHeight()); | |
| 659 | 643 |
| 660 // Add the hint saying that the window supports the sync request | 644 // Add the hint saying that the window supports the sync request |
| 661 // protocol, but don't actually set the property saying which counter | 645 // protocol, but don't actually set the property saying which counter |
| 662 // it's using. The hint should be ignored. | 646 // it's using. The hint should be ignored. |
| 663 ASSERT_TRUE( | 647 ASSERT_TRUE( |
| 664 xconn_->SetIntProperty( | 648 xconn_->SetIntProperty( |
| 665 xid, | 649 xid, |
| 666 xconn_->GetAtomOrDie("WM_PROTOCOLS"), // atom | 650 xconn_->GetAtomOrDie("WM_PROTOCOLS"), // atom |
| 667 xconn_->GetAtomOrDie("ATOM"), // type | 651 xconn_->GetAtomOrDie("ATOM"), // type |
| 668 xconn_->GetAtomOrDie("_NET_WM_SYNC_REQUEST"))); | 652 xconn_->GetAtomOrDie("_NET_WM_SYNC_REQUEST"))); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 687 // alarm's trigger at the next-greatest value. | 671 // alarm's trigger at the next-greatest value. |
| 688 int64_t initial_counter_value = xconn_->GetSyncCounterValueOrDie(counter_xid); | 672 int64_t initial_counter_value = xconn_->GetSyncCounterValueOrDie(counter_xid); |
| 689 EXPECT_NE(static_cast<int64_t>(0), initial_counter_value); | 673 EXPECT_NE(static_cast<int64_t>(0), initial_counter_value); |
| 690 int64_t next_counter_value = initial_counter_value + 1; | 674 int64_t next_counter_value = initial_counter_value + 1; |
| 691 EXPECT_EQ(next_counter_value, alarm_info->initial_trigger_value); | 675 EXPECT_EQ(next_counter_value, alarm_info->initial_trigger_value); |
| 692 | 676 |
| 693 // When we resize the window, we should consider the window as needing to | 677 // When we resize the window, we should consider the window as needing to |
| 694 // be redrawn. | 678 // be redrawn. |
| 695 MockXConnection::WindowInfo* info = xconn_->GetWindowInfoOrDie(xid); | 679 MockXConnection::WindowInfo* info = xconn_->GetWindowInfoOrDie(xid); |
| 696 info->client_messages.clear(); | 680 info->client_messages.clear(); |
| 697 win.ResizeClient(600, 600, GRAVITY_NORTHWEST); | 681 Size kSecondSize(600, 600); |
| 682 win.Resize(kSecondSize, GRAVITY_NORTHWEST); |
| 698 EXPECT_FALSE(win.client_has_redrawn_after_last_resize_); | 683 EXPECT_FALSE(win.client_has_redrawn_after_last_resize_); |
| 699 | 684 |
| 700 // We should also abstain from getting a new pixmap in response to | 685 // We should also abstain from getting a new pixmap in response to |
| 701 // ConfigureNotify events... | 686 // ConfigureNotify events... |
| 702 win.HandleConfigureNotify(600, 600); | 687 win.HandleConfigureNotify(Rect(info->bounds.position(), kSecondSize), 0); |
| 703 EXPECT_EQ(500, actor->GetWidth()); | 688 EXPECT_EQ(kFirstSize, actor->GetBounds().size()); |
| 704 EXPECT_EQ(500, actor->GetHeight()); | |
| 705 | 689 |
| 706 // ... and we should send the client a message telling it to increment the | 690 // ... and we should send the client a message telling it to increment the |
| 707 // counter when it's done redrawing. | 691 // counter when it's done redrawing. |
| 708 ASSERT_EQ(1, info->client_messages.size()); | 692 ASSERT_EQ(1, info->client_messages.size()); |
| 709 const XClientMessageEvent& msg = info->client_messages[0]; | 693 const XClientMessageEvent& msg = info->client_messages[0]; |
| 710 EXPECT_EQ(xconn_->GetAtomOrDie("WM_PROTOCOLS"), msg.message_type); | 694 EXPECT_EQ(xconn_->GetAtomOrDie("WM_PROTOCOLS"), msg.message_type); |
| 711 EXPECT_EQ(XConnection::kLongFormat, msg.format); | 695 EXPECT_EQ(XConnection::kLongFormat, msg.format); |
| 712 EXPECT_EQ(xconn_->GetAtomOrDie("_NET_WM_SYNC_REQUEST"), msg.data.l[0]); | 696 EXPECT_EQ(xconn_->GetAtomOrDie("_NET_WM_SYNC_REQUEST"), msg.data.l[0]); |
| 713 // TODO: Check timestamp in l[1]? | 697 // TODO: Check timestamp in l[1]? |
| 714 EXPECT_EQ(static_cast<uint32_t>(next_counter_value & 0xffffffff), | 698 EXPECT_EQ(static_cast<uint32_t>(next_counter_value & 0xffffffff), |
| 715 msg.data.l[2]); | 699 msg.data.l[2]); |
| 716 EXPECT_EQ(static_cast<uint32_t>((next_counter_value >> 32) & 0xffffffff), | 700 EXPECT_EQ(static_cast<uint32_t>((next_counter_value >> 32) & 0xffffffff), |
| 717 msg.data.l[3]); | 701 msg.data.l[3]); |
| 718 | 702 |
| 719 // If we get notified that the counter is at the previous value, we | 703 // If we get notified that the counter is at the previous value, we |
| 720 // should ignore it. | 704 // should ignore it. |
| 721 win.HandleSyncAlarmNotify(win.wm_sync_request_alarm_, initial_counter_value); | 705 win.HandleSyncAlarmNotify(win.wm_sync_request_alarm_, initial_counter_value); |
| 722 EXPECT_FALSE(win.client_has_redrawn_after_last_resize_); | 706 EXPECT_FALSE(win.client_has_redrawn_after_last_resize_); |
| 723 | 707 |
| 724 // Ditto if we get notified about some alarm that we don't know about | 708 // Ditto if we get notified about some alarm that we don't know about |
| 725 // (this shouldn't happen in practice). | 709 // (this shouldn't happen in practice). |
| 726 win.HandleSyncAlarmNotify(0, next_counter_value); | 710 win.HandleSyncAlarmNotify(0, next_counter_value); |
| 727 EXPECT_FALSE(win.client_has_redrawn_after_last_resize_); | 711 EXPECT_FALSE(win.client_has_redrawn_after_last_resize_); |
| 728 | 712 |
| 729 // When we get notified that the counter has increased to the next value, | 713 // When we get notified that the counter has increased to the next value, |
| 730 // we should consider the window to be redrawn and fetch an updated pixmap. | 714 // we should consider the window to be redrawn and fetch an updated pixmap. |
| 731 win.HandleSyncAlarmNotify(win.wm_sync_request_alarm_, next_counter_value); | 715 win.HandleSyncAlarmNotify(win.wm_sync_request_alarm_, next_counter_value); |
| 732 EXPECT_TRUE(win.client_has_redrawn_after_last_resize_); | 716 EXPECT_TRUE(win.client_has_redrawn_after_last_resize_); |
| 733 EXPECT_EQ(600, actor->GetWidth()); | 717 EXPECT_EQ(kSecondSize, actor->GetBounds().size()); |
| 734 EXPECT_EQ(600, actor->GetHeight()); | |
| 735 | 718 |
| 736 // If we somehow get notified that the window has been redrawn before we | 719 // If we somehow get notified that the window has been redrawn before we |
| 737 // get the ConfigureNotify, reset the pixmap immediately. | 720 // get the ConfigureNotify, reset the pixmap immediately. |
| 738 win.ResizeClient(700, 700, GRAVITY_NORTHWEST); | 721 Size kThirdSize(700, 700); |
| 722 win.Resize(kThirdSize, GRAVITY_NORTHWEST); |
| 739 win.HandleSyncAlarmNotify(win.wm_sync_request_alarm_, | 723 win.HandleSyncAlarmNotify(win.wm_sync_request_alarm_, |
| 740 win.current_wm_sync_num_); | 724 win.current_wm_sync_num_); |
| 741 EXPECT_EQ(700, actor->GetWidth()); | 725 EXPECT_EQ(kThirdSize, actor->GetBounds().size()); |
| 742 EXPECT_EQ(700, actor->GetHeight()); | |
| 743 } | 726 } |
| 744 | 727 |
| 745 // Test that we wait to fetch pixmaps for newly-created windows until the | 728 // Test that we wait to fetch pixmaps for newly-created windows until the |
| 746 // client tells us that they've been painted. | 729 // client tells us that they've been painted. |
| 747 TEST_F(WindowTest, DeferFetchingPixmapUntilPainted) { | 730 TEST_F(WindowTest, DeferFetchingPixmapUntilPainted) { |
| 748 // Create a window and configure it to use _NET_WM_SYNC_REQUEST. | 731 // Create a window and configure it to use _NET_WM_SYNC_REQUEST. |
| 749 XWindow xid = CreateSimpleWindow(); | 732 XWindow xid = CreateSimpleWindow(); |
| 750 ConfigureWindowForSyncRequestProtocol(xid); | 733 ConfigureWindowForSyncRequestProtocol(xid); |
| 751 XConnection::WindowGeometry geometry; | 734 XConnection::WindowGeometry geometry; |
| 752 ASSERT_TRUE(xconn_->GetWindowGeometry(xid, &geometry)); | 735 ASSERT_TRUE(xconn_->GetWindowGeometry(xid, &geometry)); |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 900 win.HandleMapNotify(); | 883 win.HandleMapNotify(); |
| 901 EXPECT_EQ(kNewSize, win.actor()->GetBounds().size()); | 884 EXPECT_EQ(kNewSize, win.actor()->GetBounds().size()); |
| 902 | 885 |
| 903 // Turn on the shadow while we're in this brief state where we have a | 886 // Turn on the shadow while we're in this brief state where we have a |
| 904 // 200x400 actor but have only heard about the 1x1 size from the X | 887 // 200x400 actor but have only heard about the 1x1 size from the X |
| 905 // server. The shadow should take the actor's size. | 888 // server. The shadow should take the actor's size. |
| 906 win.SetShadowType(Shadow::TYPE_RECTANGULAR); | 889 win.SetShadowType(Shadow::TYPE_RECTANGULAR); |
| 907 EXPECT_EQ(kNewSize, win.shadow()->bounds().size()); | 890 EXPECT_EQ(kNewSize, win.shadow()->bounds().size()); |
| 908 | 891 |
| 909 // Now send the ConfigureNotify and check that nothing changes. | 892 // Now send the ConfigureNotify and check that nothing changes. |
| 910 win.HandleConfigureNotify(kNewSize.width, kNewSize.height); | 893 win.HandleConfigureNotify(Rect(Point(0, 0), kNewSize), 0); |
| 911 EXPECT_EQ(kNewSize, win.actor()->GetBounds().size()); | 894 EXPECT_EQ(kNewSize, win.actor()->GetBounds().size()); |
| 912 } | 895 } |
| 913 | 896 |
| 914 // Test that when we ask a window to simultaneously move and resize itself (that | 897 // Test that when we ask a window to simultaneously move and resize itself (that |
| 915 // is, we request a resize with non-northwest gravity), the actor's position and | 898 // is, we request a resize with non-northwest gravity), the actor's position and |
| 916 // size are updated atomically, rather than its position getting changed | 899 // size are updated atomically, rather than its position getting changed |
| 917 // immediately and the resize only happening after we fetch the new pixmap. | 900 // immediately and the resize only happening after we fetch the new pixmap. |
| 918 TEST_F(WindowTest, SimultaneousMoveAndResize) { | 901 TEST_F(WindowTest, SimultaneousMoveAndResize) { |
| 919 // Create and map a window. | 902 // Create and map a window. |
| 920 const Rect kOrigBounds(100, 150, 300, 250); | 903 const Rect kOrigBounds(100, 150, 300, 250); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 935 MockXConnection::WindowInfo* info = xconn_->GetWindowInfoOrDie(xid); | 918 MockXConnection::WindowInfo* info = xconn_->GetWindowInfoOrDie(xid); |
| 936 EXPECT_EQ(kOrigBounds, info->bounds); | 919 EXPECT_EQ(kOrigBounds, info->bounds); |
| 937 MockCompositor::TexturePixmapActor* actor = GetMockActorForWindow(&win); | 920 MockCompositor::TexturePixmapActor* actor = GetMockActorForWindow(&win); |
| 938 EXPECT_EQ(kOrigBounds, actor->GetBounds()); | 921 EXPECT_EQ(kOrigBounds, actor->GetBounds()); |
| 939 EXPECT_EQ(kOrigBounds.x, win.composited_x()); | 922 EXPECT_EQ(kOrigBounds.x, win.composited_x()); |
| 940 EXPECT_EQ(kOrigBounds.y, win.composited_y()); | 923 EXPECT_EQ(kOrigBounds.y, win.composited_y()); |
| 941 | 924 |
| 942 // Now make the window 50 pixels wider and taller with southeast gravity. | 925 // Now make the window 50 pixels wider and taller with southeast gravity. |
| 943 // In other words, its origin should also move 50 pixels up and to the left. | 926 // In other words, its origin should also move 50 pixels up and to the left. |
| 944 const Rect kNewBounds(50, 100, 350, 300); | 927 const Rect kNewBounds(50, 100, 350, 300); |
| 945 win.ResizeClient(kNewBounds.width, kNewBounds.height, GRAVITY_SOUTHEAST); | 928 win.Resize(kNewBounds.size(), GRAVITY_SOUTHEAST); |
| 946 | 929 |
| 947 // A request should've been sent to the X server asking for the new bounds, so | 930 // A request should've been sent to the X server asking for the new bounds, so |
| 948 // the client window should be resized. The actor should still be at the old | 931 // the client window should be resized. The actor should still be at the old |
| 949 // size (since we can't fetch its bitmap yet) and also at the old position (so | 932 // size (since we can't fetch its bitmap yet) and also at the old position (so |
| 950 // we can make the move and resize happen atomically onscreen later). | 933 // we can make the move and resize happen atomically onscreen later). |
| 951 EXPECT_EQ(kNewBounds, info->bounds); | 934 EXPECT_EQ(kNewBounds, info->bounds); |
| 952 EXPECT_EQ(kOrigBounds, actor->GetBounds()); | 935 EXPECT_EQ(kOrigBounds, actor->GetBounds()); |
| 953 EXPECT_EQ(kNewBounds.x, win.composited_x()); | 936 EXPECT_EQ(kNewBounds.x, win.composited_x()); |
| 954 EXPECT_EQ(kNewBounds.y, win.composited_y()); | 937 EXPECT_EQ(kNewBounds.y, win.composited_y()); |
| 955 | 938 |
| 956 // After we've received notification that the new pixmap is available, the | 939 // After we've received notification that the new pixmap is available, the |
| 957 // actor should be both resized and moved to the requested position. | 940 // actor should be both resized and moved to the requested position. |
| 958 win.HandleConfigureNotify(kNewBounds.width, kNewBounds.height); | 941 win.HandleConfigureNotify(kNewBounds, 0); |
| 959 EXPECT_EQ(kNewBounds, actor->GetBounds()); | 942 EXPECT_EQ(kNewBounds, actor->GetBounds()); |
| 960 EXPECT_EQ(kNewBounds.x, win.composited_x()); | 943 EXPECT_EQ(kNewBounds.x, win.composited_x()); |
| 961 EXPECT_EQ(kNewBounds.y, win.composited_y()); | 944 EXPECT_EQ(kNewBounds.y, win.composited_y()); |
| 962 | 945 |
| 963 // Move the actor to a completely different position. | 946 // Move the actor to a completely different position. |
| 964 const Point kCompositedPosition(500, 600); | 947 const Point kCompositedPosition(500, 600); |
| 965 win.MoveComposited(kCompositedPosition.x, kCompositedPosition.y, 0); | 948 win.MoveComposited(kCompositedPosition.x, kCompositedPosition.y, 0); |
| 966 EXPECT_EQ(Rect(kCompositedPosition, kNewBounds.size()), actor->GetBounds()); | 949 EXPECT_EQ(Rect(kCompositedPosition, kNewBounds.size()), actor->GetBounds()); |
| 967 EXPECT_EQ(kCompositedPosition.x, win.composited_x()); | 950 EXPECT_EQ(kCompositedPosition.x, win.composited_x()); |
| 968 EXPECT_EQ(kCompositedPosition.y, win.composited_y()); | 951 EXPECT_EQ(kCompositedPosition.y, win.composited_y()); |
| 969 | 952 |
| 970 // Now resize the window back to its old size, again with southeast gravity. | 953 // Now resize the window back to its old size, again with southeast gravity. |
| 971 // The actor shouldn't move, but we should update the |composited_x| and | 954 // The actor shouldn't move, but we should update the |composited_x| and |
| 972 // |composited_y| fields. | 955 // |composited_y| fields. |
| 973 win.ResizeClient(kOrigBounds.width, kOrigBounds.height, GRAVITY_SOUTHEAST); | 956 win.Resize(kOrigBounds.size(), GRAVITY_SOUTHEAST); |
| 974 EXPECT_EQ(kOrigBounds, info->bounds); | 957 EXPECT_EQ(kOrigBounds, info->bounds); |
| 975 EXPECT_EQ(Rect(kCompositedPosition, kNewBounds.size()), actor->GetBounds()); | 958 EXPECT_EQ(Rect(kCompositedPosition, kNewBounds.size()), actor->GetBounds()); |
| 976 const Point kOffsetCompositedPosition( | 959 const Point kOffsetCompositedPosition( |
| 977 kCompositedPosition.x + (kNewBounds.width - kOrigBounds.width), | 960 kCompositedPosition.x + (kNewBounds.width - kOrigBounds.width), |
| 978 kCompositedPosition.y + (kNewBounds.height - kOrigBounds.height)); | 961 kCompositedPosition.y + (kNewBounds.height - kOrigBounds.height)); |
| 979 EXPECT_EQ(kOffsetCompositedPosition.x, win.composited_x()); | 962 EXPECT_EQ(kOffsetCompositedPosition.x, win.composited_x()); |
| 980 EXPECT_EQ(kOffsetCompositedPosition.y, win.composited_y()); | 963 EXPECT_EQ(kOffsetCompositedPosition.y, win.composited_y()); |
| 981 | 964 |
| 982 // After getting notification about the pixmap, the actor should be resized | 965 // After getting notification about the pixmap, the actor should be resized |
| 983 // and moved to the new position. | 966 // and moved to the new position. |
| 984 win.HandleConfigureNotify(kOrigBounds.width, kOrigBounds.height); | 967 win.HandleConfigureNotify(kOrigBounds, 0); |
| 985 EXPECT_EQ(Rect(kOffsetCompositedPosition, kOrigBounds.size()), | 968 EXPECT_EQ(Rect(kOffsetCompositedPosition, kOrigBounds.size()), |
| 986 actor->GetBounds()); | 969 actor->GetBounds()); |
| 987 | 970 |
| 988 // Move the composited window back to the client window's position and scale | 971 // Move the composited window back to the client window's position and scale |
| 989 // it to 50% of its original size. | 972 // it to 50% of its original size. |
| 990 win.MoveComposited(kOrigBounds.x, kOrigBounds.y, 0); | 973 win.MoveComposited(kOrigBounds.x, kOrigBounds.y, 0); |
| 991 const double kCompositedScale = 0.5; | 974 const double kCompositedScale = 0.5; |
| 992 win.ScaleComposited(kCompositedScale, kCompositedScale, 0); | 975 win.ScaleComposited(kCompositedScale, kCompositedScale, 0); |
| 993 | 976 |
| 994 // Resize the client again. The amount that the composited window is moved | 977 // Resize the client again. The amount that the composited window is moved |
| 995 // should be scaled by its scaling factor. | 978 // should be scaled by its scaling factor. |
| 996 win.ResizeClient(kNewBounds.width, kNewBounds.height, GRAVITY_SOUTHEAST); | 979 win.Resize(kNewBounds.size(), GRAVITY_SOUTHEAST); |
| 997 const Point kScaledCompositedPosition( | 980 const Point kScaledCompositedPosition( |
| 998 kOrigBounds.x + kCompositedScale * (kNewBounds.x - kOrigBounds.x), | 981 kOrigBounds.x + kCompositedScale * (kNewBounds.x - kOrigBounds.x), |
| 999 kOrigBounds.y + kCompositedScale * (kNewBounds.y - kOrigBounds.y)); | 982 kOrigBounds.y + kCompositedScale * (kNewBounds.y - kOrigBounds.y)); |
| 1000 EXPECT_EQ(kScaledCompositedPosition.x, win.composited_x()); | 983 EXPECT_EQ(kScaledCompositedPosition.x, win.composited_x()); |
| 1001 EXPECT_EQ(kScaledCompositedPosition.y, win.composited_y()); | 984 EXPECT_EQ(kScaledCompositedPosition.y, win.composited_y()); |
| 1002 | 985 |
| 1003 win.HandleConfigureNotify(kNewBounds.width, kNewBounds.height); | 986 win.HandleConfigureNotify(kNewBounds, 0); |
| 1004 EXPECT_EQ(Rect(kScaledCompositedPosition, kNewBounds.size()), | 987 EXPECT_EQ(Rect(kScaledCompositedPosition, kNewBounds.size()), |
| 1005 actor->GetBounds()); | 988 actor->GetBounds()); |
| 1006 } | 989 } |
| 1007 | 990 |
| 1008 // Exercises the new interface for managing both X and composited windows | 991 // Exercises the new interface for managing both X and composited windows |
| 1009 // simultaneously (SetVisibility() and Move()). | 992 // simultaneously (SetVisibility() and Move()). |
| 1010 TEST_F(WindowTest, SetVisibility) { | 993 TEST_F(WindowTest, SetVisibility) { |
| 1011 // Create and map a window. | 994 // Create and map a window. |
| 1012 const Rect kOrigBounds(100, 150, 300, 250); | 995 const Rect kOrigBounds(100, 150, 300, 250); |
| 1013 XWindow xid = xconn_->CreateWindow(xconn_->GetRootWindow(), | 996 XWindow xid = xconn_->CreateWindow(xconn_->GetRootWindow(), |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1183 win2.HandleFreezeUpdatesPropertyChange(false); | 1166 win2.HandleFreezeUpdatesPropertyChange(false); |
| 1184 EXPECT_NE(0, win2.pixmap_); | 1167 EXPECT_NE(0, win2.pixmap_); |
| 1185 EXPECT_TRUE(win2.has_initial_pixmap()); | 1168 EXPECT_TRUE(win2.has_initial_pixmap()); |
| 1186 } | 1169 } |
| 1187 | 1170 |
| 1188 } // namespace window_manager | 1171 } // namespace window_manager |
| 1189 | 1172 |
| 1190 int main(int argc, char** argv) { | 1173 int main(int argc, char** argv) { |
| 1191 return window_manager::InitAndRunTests(&argc, argv, &FLAGS_logtostderr); | 1174 return window_manager::InitAndRunTests(&argc, argv, &FLAGS_logtostderr); |
| 1192 } | 1175 } |
| OLD | NEW |