| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 843 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 854 WindowTreeClient* embedded1 = Embed(child1).client; | 854 WindowTreeClient* embedded1 = Embed(child1).client; |
| 855 ASSERT_NE(nullptr, embedded1); | 855 ASSERT_NE(nullptr, embedded1); |
| 856 WindowTreeClient* embedded2 = Embed(child2).client; | 856 WindowTreeClient* embedded2 = Embed(child2).client; |
| 857 ASSERT_NE(nullptr, embedded2); | 857 ASSERT_NE(nullptr, embedded2); |
| 858 | 858 |
| 859 Window* child11 = NewVisibleWindow(GetFirstRoot(embedded1), embedded1); | 859 Window* child11 = NewVisibleWindow(GetFirstRoot(embedded1), embedded1); |
| 860 Window* child21 = NewVisibleWindow(GetFirstRoot(embedded2), embedded2); | 860 Window* child21 = NewVisibleWindow(GetFirstRoot(embedded2), embedded2); |
| 861 | 861 |
| 862 WaitForTreeSizeToMatch(parent, 6); | 862 WaitForTreeSizeToMatch(parent, 6); |
| 863 | 863 |
| 864 // |child2| and |child3| are stacked about |child1|. | 864 EXPECT_EQ(0, ValidIndexOf(parent->children(), child1)); |
| 865 EXPECT_GT(ValidIndexOf(parent->children(), child2), | 865 // NOTE: |child3| is after |child1| as |child3| is a transient child of |
| 866 ValidIndexOf(parent->children(), child1)); | 866 // |child1|. |
| 867 EXPECT_GT(ValidIndexOf(parent->children(), child3), | 867 EXPECT_EQ(1, ValidIndexOf(parent->children(), child3)); |
| 868 ValidIndexOf(parent->children(), child1)); | 868 EXPECT_EQ(2, ValidIndexOf(parent->children(), child2)); |
| 869 | 869 |
| 870 // Set focus on |child11|. This should activate |child1|, and raise it over | 870 // Set focus on |child11|, order of windows should not change. |
| 871 // |child2|. But |child3| should still be above |child1| because of | |
| 872 // transiency. | |
| 873 child11->SetFocus(); | 871 child11->SetFocus(); |
| 874 ASSERT_TRUE(WaitForWindowToHaveFocus(child11)); | 872 ASSERT_TRUE(WaitForWindowToHaveFocus(child11)); |
| 875 ASSERT_TRUE(WaitForWindowToHaveFocus( | 873 ASSERT_TRUE(WaitForWindowToHaveFocus( |
| 876 GetChildWindowByServerId(window_manager(), server_id(child11)))); | 874 GetChildWindowByServerId(window_manager(), server_id(child11)))); |
| 877 EXPECT_EQ(server_id(child11), | 875 EXPECT_EQ(server_id(child11), |
| 878 server_id(window_manager()->GetFocusedWindow())); | 876 server_id(window_manager()->GetFocusedWindow())); |
| 879 EXPECT_EQ(server_id(child11), server_id(embedded1->GetFocusedWindow())); | 877 EXPECT_EQ(server_id(child11), server_id(embedded1->GetFocusedWindow())); |
| 880 EXPECT_EQ(nullptr, embedded2->GetFocusedWindow()); | 878 EXPECT_EQ(nullptr, embedded2->GetFocusedWindow()); |
| 881 EXPECT_GT(ValidIndexOf(parent->children(), child1), | 879 EXPECT_EQ(0, ValidIndexOf(parent->children(), child1)); |
| 882 ValidIndexOf(parent->children(), child2)); | 880 EXPECT_EQ(1, ValidIndexOf(parent->children(), child3)); |
| 883 EXPECT_GT(ValidIndexOf(parent->children(), child3), | 881 EXPECT_EQ(2, ValidIndexOf(parent->children(), child2)); |
| 884 ValidIndexOf(parent->children(), child1)); | |
| 885 | 882 |
| 886 // Set focus on |child21|. This should activate |child2|, and raise it over | 883 // Set focus on |child21|. This should activate |child2|. Again, order should |
| 887 // |child1|. | 884 // not change. |
| 888 child21->SetFocus(); | 885 child21->SetFocus(); |
| 889 ASSERT_TRUE(WaitForWindowToHaveFocus(child21)); | 886 ASSERT_TRUE(WaitForWindowToHaveFocus(child21)); |
| 890 ASSERT_TRUE(WaitForWindowToHaveFocus( | 887 ASSERT_TRUE(WaitForWindowToHaveFocus( |
| 891 GetChildWindowByServerId(window_manager(), server_id(child21)))); | 888 GetChildWindowByServerId(window_manager(), server_id(child21)))); |
| 892 EXPECT_EQ(server_id(child21), | 889 EXPECT_EQ(server_id(child21), |
| 893 server_id(window_manager()->GetFocusedWindow())); | 890 server_id(window_manager()->GetFocusedWindow())); |
| 894 EXPECT_EQ(server_id(child21), server_id(embedded2->GetFocusedWindow())); | 891 EXPECT_EQ(server_id(child21), server_id(embedded2->GetFocusedWindow())); |
| 895 EXPECT_TRUE(WaitForNoWindowToHaveFocus(embedded1)); | 892 EXPECT_TRUE(WaitForNoWindowToHaveFocus(embedded1)); |
| 896 EXPECT_EQ(nullptr, embedded1->GetFocusedWindow()); | 893 EXPECT_EQ(nullptr, embedded1->GetFocusedWindow()); |
| 897 EXPECT_GT(ValidIndexOf(parent->children(), child2), | 894 EXPECT_EQ(0, ValidIndexOf(parent->children(), child1)); |
| 898 ValidIndexOf(parent->children(), child1)); | 895 EXPECT_EQ(1, ValidIndexOf(parent->children(), child3)); |
| 899 EXPECT_GT(ValidIndexOf(parent->children(), child3), | 896 EXPECT_EQ(2, ValidIndexOf(parent->children(), child2)); |
| 900 ValidIndexOf(parent->children(), child1)); | |
| 901 } | 897 } |
| 902 | 898 |
| 903 TEST_F(WindowServerTest, ActivationNext) { | 899 TEST_F(WindowServerTest, ActivationNext) { |
| 904 Window* parent = GetFirstWMRoot(); | 900 Window* parent = GetFirstWMRoot(); |
| 905 Window* child1 = NewVisibleWindow(parent, window_manager()); | 901 Window* child1 = NewVisibleWindow(parent, window_manager()); |
| 906 Window* child2 = NewVisibleWindow(parent, window_manager()); | 902 Window* child2 = NewVisibleWindow(parent, window_manager()); |
| 907 Window* child3 = NewVisibleWindow(parent, window_manager()); | 903 Window* child3 = NewVisibleWindow(parent, window_manager()); |
| 908 | 904 |
| 909 WindowTreeClient* embedded1 = Embed(child1).client; | 905 WindowTreeClient* embedded1 = Embed(child1).client; |
| 910 ASSERT_NE(nullptr, embedded1); | 906 ASSERT_NE(nullptr, embedded1); |
| 911 WindowTreeClient* embedded2 = Embed(child2).client; | 907 WindowTreeClient* embedded2 = Embed(child2).client; |
| 912 ASSERT_NE(nullptr, embedded2); | 908 ASSERT_NE(nullptr, embedded2); |
| 913 WindowTreeClient* embedded3 = Embed(child3).client; | 909 WindowTreeClient* embedded3 = Embed(child3).client; |
| 914 ASSERT_NE(nullptr, embedded3); | 910 ASSERT_NE(nullptr, embedded3); |
| 915 | 911 |
| 916 Window* child11 = NewVisibleWindow(GetFirstRoot(embedded1), embedded1); | 912 Window* child11 = NewVisibleWindow(GetFirstRoot(embedded1), embedded1); |
| 917 Window* child21 = NewVisibleWindow(GetFirstRoot(embedded2), embedded2); | 913 Window* child21 = NewVisibleWindow(GetFirstRoot(embedded2), embedded2); |
| 918 Window* child31 = NewVisibleWindow(GetFirstRoot(embedded3), embedded3); | 914 Window* child31 = NewVisibleWindow(GetFirstRoot(embedded3), embedded3); |
| 919 WaitForTreeSizeToMatch(parent, 7); | 915 WaitForTreeSizeToMatch(parent, 7); |
| 920 | 916 |
| 921 Window* expecteds[] = { child3, child2, child1, child3, nullptr }; | |
| 922 Window* focused[] = { child31, child21, child11, child31, nullptr }; | 917 Window* focused[] = { child31, child21, child11, child31, nullptr }; |
| 923 for (size_t index = 0; expecteds[index]; ++index) { | 918 for (size_t index = 0; focused[index]; ++index) { |
| 924 window_manager_client()->ActivateNextWindow(); | 919 window_manager_client()->ActivateNextWindow(); |
| 925 WaitForWindowToHaveFocus(focused[index]); | 920 WaitForWindowToHaveFocus(focused[index]); |
| 926 EXPECT_TRUE(focused[index]->HasFocus()); | 921 EXPECT_TRUE(focused[index]->HasFocus()); |
| 927 EXPECT_EQ(parent->children().back(), expecteds[index]); | |
| 928 } | 922 } |
| 929 } | 923 } |
| 930 | 924 |
| 931 namespace { | 925 namespace { |
| 932 | 926 |
| 933 class DestroyedChangedObserver : public WindowObserver { | 927 class DestroyedChangedObserver : public WindowObserver { |
| 934 public: | 928 public: |
| 935 DestroyedChangedObserver(Window* window, bool* got_destroy) | 929 DestroyedChangedObserver(Window* window, bool* got_destroy) |
| 936 : window_(window), got_destroy_(got_destroy) { | 930 : window_(window), got_destroy_(got_destroy) { |
| 937 window_->AddObserver(this); | 931 window_->AddObserver(this); |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1130 ASSERT_TRUE(window_in_wm); | 1124 ASSERT_TRUE(window_in_wm); |
| 1131 | 1125 |
| 1132 // Change the bounds in the wm, and make sure the child sees it. | 1126 // Change the bounds in the wm, and make sure the child sees it. |
| 1133 window_in_wm->SetBounds(gfx::Rect(1, 11, 12, 101)); | 1127 window_in_wm->SetBounds(gfx::Rect(1, 11, 12, 101)); |
| 1134 ASSERT_TRUE(WaitForBoundsToChange(window_in_second_client)); | 1128 ASSERT_TRUE(WaitForBoundsToChange(window_in_second_client)); |
| 1135 EXPECT_EQ(gfx::Rect(1, 11, 12, 101), window_in_second_client->bounds()); | 1129 EXPECT_EQ(gfx::Rect(1, 11, 12, 101), window_in_second_client->bounds()); |
| 1136 } | 1130 } |
| 1137 | 1131 |
| 1138 } // namespace ws | 1132 } // namespace ws |
| 1139 } // namespace ui | 1133 } // namespace ui |
| OLD | NEW |