| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/logging.h" | 6 #include "base/logging.h" |
| 7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
| 8 #include "components/mus/public/cpp/tests/window_server_test_base.h" | 8 #include "components/mus/public/cpp/tests/window_server_test_base.h" |
| 9 #include "components/mus/public/cpp/util.h" | 9 #include "components/mus/public/cpp/util.h" |
| 10 #include "components/mus/public/cpp/window_observer.h" | 10 #include "components/mus/public/cpp/window_observer.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 class ClientAreaChangeObserver : public WindowObserver { | 54 class ClientAreaChangeObserver : public WindowObserver { |
| 55 public: | 55 public: |
| 56 explicit ClientAreaChangeObserver(Window* window) : window_(window) { | 56 explicit ClientAreaChangeObserver(Window* window) : window_(window) { |
| 57 window_->AddObserver(this); | 57 window_->AddObserver(this); |
| 58 } | 58 } |
| 59 ~ClientAreaChangeObserver() override { window_->RemoveObserver(this); } | 59 ~ClientAreaChangeObserver() override { window_->RemoveObserver(this); } |
| 60 | 60 |
| 61 private: | 61 private: |
| 62 // Overridden from WindowObserver: | 62 // Overridden from WindowObserver: |
| 63 void OnWindowClientAreaChanged(Window* window, | 63 void OnWindowClientAreaChanged(Window* window, |
| 64 const gfx::Rect& old_client_area) override { | 64 const gfx::Insets& old_client_area) override { |
| 65 DCHECK_EQ(window, window_); | 65 DCHECK_EQ(window, window_); |
| 66 EXPECT_TRUE(WindowServerTestBase::QuitRunLoop()); | 66 EXPECT_TRUE(WindowServerTestBase::QuitRunLoop()); |
| 67 } | 67 } |
| 68 | 68 |
| 69 Window* window_; | 69 Window* window_; |
| 70 | 70 |
| 71 MOJO_DISALLOW_COPY_AND_ASSIGN(ClientAreaChangeObserver); | 71 MOJO_DISALLOW_COPY_AND_ASSIGN(ClientAreaChangeObserver); |
| 72 }; | 72 }; |
| 73 | 73 |
| 74 // Wait until the bounds of the supplied window change; returns false on | 74 // Wait until the bounds of the supplied window change; returns false on |
| (...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 867 EXPECT_EQ(result4.connection_id, result4.connection->GetConnectionId()); | 867 EXPECT_EQ(result4.connection_id, result4.connection->GetConnectionId()); |
| 868 } | 868 } |
| 869 | 869 |
| 870 TEST_F(WindowServerTest, ClientAreaChanged) { | 870 TEST_F(WindowServerTest, ClientAreaChanged) { |
| 871 Window* embed_window = window_manager()->NewWindow(); | 871 Window* embed_window = window_manager()->NewWindow(); |
| 872 window_manager()->GetRoot()->AddChild(embed_window); | 872 window_manager()->GetRoot()->AddChild(embed_window); |
| 873 | 873 |
| 874 WindowTreeConnection* embedded_connection = Embed(embed_window).connection; | 874 WindowTreeConnection* embedded_connection = Embed(embed_window).connection; |
| 875 | 875 |
| 876 // Verify change from embedded makes it to parent. | 876 // Verify change from embedded makes it to parent. |
| 877 embedded_connection->GetRoot()->SetClientArea(gfx::Rect(1, 2, 3, 4)); | 877 embedded_connection->GetRoot()->SetClientArea(gfx::Insets(1, 2, 3, 4)); |
| 878 ASSERT_TRUE(WaitForClientAreaToChange(embed_window)); | 878 ASSERT_TRUE(WaitForClientAreaToChange(embed_window)); |
| 879 EXPECT_TRUE(gfx::Rect(1, 2, 3, 4) == embed_window->client_area()); | 879 EXPECT_TRUE(gfx::Insets(1, 2, 3, 4) == embed_window->client_area()); |
| 880 | 880 |
| 881 // Verify bounds change results in resetting client area in embedded. | 881 // Changing bounds shouldn't effect client area. |
| 882 embed_window->SetBounds(gfx::Rect(21, 22, 23, 24)); | 882 embed_window->SetBounds(gfx::Rect(21, 22, 23, 24)); |
| 883 WaitForBoundsToChange(embedded_connection->GetRoot()); | 883 WaitForBoundsToChange(embedded_connection->GetRoot()); |
| 884 EXPECT_TRUE(gfx::Rect(21, 22, 23, 24) == | 884 EXPECT_TRUE(gfx::Rect(21, 22, 23, 24) == |
| 885 embedded_connection->GetRoot()->bounds()); | 885 embedded_connection->GetRoot()->bounds()); |
| 886 EXPECT_TRUE(gfx::Rect(0, 0, 23, 24) == | 886 EXPECT_TRUE(gfx::Insets(1, 2, 3, 4) == |
| 887 embedded_connection->GetRoot()->client_area()); | 887 embedded_connection->GetRoot()->client_area()); |
| 888 } | 888 } |
| 889 | 889 |
| 890 } // namespace ws | 890 } // namespace ws |
| 891 | 891 |
| 892 } // namespace mus | 892 } // namespace mus |
| OLD | NEW |