| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ash/wm/compact_layout_manager.h" | 5 #include "ash/wm/compact_layout_manager.h" |
| 6 | 6 |
| 7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "ash/shell_window_ids.h" | 8 #include "ash/shell_window_ids.h" |
| 9 #include "ash/test/aura_shell_test_base.h" | 9 #include "ash/test/aura_shell_test_base.h" |
| 10 #include "ash/wm/shelf_layout_manager.h" | 10 #include "ash/wm/shelf_layout_manager.h" |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 EXPECT_TRUE(widget->IsVisible()); | 120 EXPECT_TRUE(widget->IsVisible()); |
| 121 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); | 121 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); |
| 122 EXPECT_FALSE(widget->IsVisible()); | 122 EXPECT_FALSE(widget->IsVisible()); |
| 123 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); | 123 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); |
| 124 EXPECT_TRUE(widget->IsVisible()); | 124 EXPECT_TRUE(widget->IsVisible()); |
| 125 } | 125 } |
| 126 | 126 |
| 127 TEST_F(CompactLayoutManagerTest, TransitionTest) { | 127 TEST_F(CompactLayoutManagerTest, TransitionTest) { |
| 128 // Assert on viewport size to be the host size. | 128 // Assert on viewport size to be the host size. |
| 129 ASSERT_EQ(kMaxWidth, default_container_layer_width()); | 129 ASSERT_EQ(kMaxWidth, default_container_layer_width()); |
| 130 // Create 3 windows, check that the layer grow as each one is added | 130 // Create 3 windows, check that the layer doesn't grow as each one is added |
| 131 // to the layout. | 131 // to the layout. |
| 132 aura::Window* window1 = CreateNormalWindow(0); | 132 aura::Window* window1 = CreateNormalWindow(0); |
| 133 EXPECT_EQ(kMaxWidth, default_container_layer_width()); | 133 EXPECT_EQ(kMaxWidth, default_container_layer_width()); |
| 134 aura::Window* window2 = CreateNormalWindow(1); | 134 aura::Window* window2 = CreateNormalWindow(1); |
| 135 EXPECT_EQ(kMaxWidth * 2, default_container_layer_width()); | 135 EXPECT_EQ(kMaxWidth, default_container_layer_width()); |
| 136 aura::Window* window3 = CreateNormalWindow(2); | 136 aura::Window* window3 = CreateNormalWindow(2); |
| 137 EXPECT_EQ(kMaxWidth * 3, default_container_layer_width()); | 137 EXPECT_EQ(kMaxWidth, default_container_layer_width()); |
| 138 animation_element()->Step(base::TimeTicks::Now() + | 138 animation_element()->Step(base::TimeTicks::Now() + |
| 139 base::TimeDelta::FromSeconds(1)); | 139 base::TimeDelta::FromSeconds(1)); |
| 140 RunAllPendingInMessageLoop(); | 140 RunAllPendingInMessageLoop(); |
| 141 | 141 |
| 142 // Check laid out position of the windows. | 142 // Check laid out position of the windows. |
| 143 EXPECT_EQ(0, window1->bounds().x()); | 143 EXPECT_EQ(-kMaxWidth * 2, window1->bounds().x()); |
| 144 EXPECT_EQ(kMaxWidth, window2->bounds().x()); | 144 EXPECT_EQ(-kMaxWidth, window2->bounds().x()); |
| 145 EXPECT_EQ(kMaxWidth * 2, window3->bounds().x()); | 145 EXPECT_EQ(0, window3->bounds().x()); |
| 146 | 146 |
| 147 // Check layer transformation. | 147 // Check layer transformation. |
| 148 ui::Transform target_transform; | 148 ui::Transform target_transform; |
| 149 target_transform.ConcatTranslate(-window3->bounds().x(), 0); | |
| 150 EXPECT_EQ(target_transform, default_container_layer_transform()); | 149 EXPECT_EQ(target_transform, default_container_layer_transform()); |
| 151 RunAllPendingInMessageLoop(); | 150 RunAllPendingInMessageLoop(); |
| 152 | 151 |
| 153 // Check that only one window is visible. | 152 // Check that only one window is visible. |
| 154 EXPECT_EQ(window3, layout_manager_->current_window_); | 153 EXPECT_EQ(window3, layout_manager_->current_window_); |
| 155 EXPECT_FALSE(window1->IsVisible()); | 154 EXPECT_FALSE(window1->IsVisible()); |
| 156 EXPECT_FALSE(window2->IsVisible()); | 155 EXPECT_FALSE(window2->IsVisible()); |
| 157 EXPECT_TRUE(window3->IsVisible()); | 156 EXPECT_TRUE(window3->IsVisible()); |
| 158 | 157 |
| 159 // That window disappear, check that we transform the layer, and | 158 // That window disappear, check that we transform the layer, and |
| 160 // again only have one window visible. | 159 // again only have one window visible. |
| 161 window3->Hide(); | 160 window3->Hide(); |
| 162 animation_element()->Step(base::TimeTicks::Now() + | 161 animation_element()->Step(base::TimeTicks::Now() + |
| 163 base::TimeDelta::FromSeconds(1)); | 162 base::TimeDelta::FromSeconds(1)); |
| 164 ui::Transform target_transform1; | 163 |
| 165 target_transform1.ConcatTranslate(-window1->bounds().x(), 0); | 164 // Check laid out position of the windows. |
| 166 EXPECT_EQ(target_transform1, default_container_layer_transform()); | 165 EXPECT_EQ(0, window1->bounds().x()); |
| 166 EXPECT_EQ(kMaxWidth, window2->bounds().x()); |
| 167 |
| 167 EXPECT_TRUE(window1->IsVisible()); | 168 EXPECT_TRUE(window1->IsVisible()); |
| 168 EXPECT_FALSE(window2->IsVisible()); | 169 EXPECT_FALSE(window2->IsVisible()); |
| 169 EXPECT_FALSE(window3->IsVisible()); | 170 EXPECT_FALSE(window3->IsVisible()); |
| 170 EXPECT_EQ(window1, layout_manager_->current_window_); | 171 EXPECT_EQ(window1, layout_manager_->current_window_); |
| 171 } | 172 } |
| 172 | 173 |
| 173 TEST_F(CompactLayoutManagerTest, SwitchToNextVisibleWindow) { | 174 TEST_F(CompactLayoutManagerTest, SwitchToNextVisibleWindow) { |
| 174 // Create 3 windows | 175 // Create 3 windows |
| 175 aura::Window* window1 = CreateNormalWindow(0); | 176 aura::Window* window1 = CreateNormalWindow(0); |
| 176 window1->Hide(); // Hide window1 before its layer marked invisible. | 177 window1->Hide(); // Hide window1 before its layer marked invisible. |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 delete window1; | 220 delete window1; |
| 220 delete window2; | 221 delete window2; |
| 221 delete window3; | 222 delete window3; |
| 222 | 223 |
| 223 // No current window now. | 224 // No current window now. |
| 224 EXPECT_EQ(NULL, layout_manager_->current_window_); | 225 EXPECT_EQ(NULL, layout_manager_->current_window_); |
| 225 } | 226 } |
| 226 | 227 |
| 227 } // namespace internal | 228 } // namespace internal |
| 228 } // namespace ash | 229 } // namespace ash |
| OLD | NEW |