Chromium Code Reviews| 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/root_window_controller.h" | 5 #include "ash/root_window_controller.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "ash/common/session/session_controller.h" | 9 #include "ash/common/session/session_controller.h" |
| 10 #include "ash/common/session/session_state_delegate.h" | 10 #include "ash/common/session/session_state_delegate.h" |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 146 normal->GetNativeView()->GetBoundsInRootWindow().ToString()); | 146 normal->GetNativeView()->GetBoundsInRootWindow().ToString()); |
| 147 | 147 |
| 148 views::Widget* maximized = CreateTestWidget(gfx::Rect(700, 10, 100, 100)); | 148 views::Widget* maximized = CreateTestWidget(gfx::Rect(700, 10, 100, 100)); |
| 149 maximized->Maximize(); | 149 maximized->Maximize(); |
| 150 EXPECT_EQ(root_windows[1], maximized->GetNativeView()->GetRootWindow()); | 150 EXPECT_EQ(root_windows[1], maximized->GetNativeView()->GetRootWindow()); |
| 151 EXPECT_EQ(gfx::Rect(600, 0, 300, 252).ToString(), | 151 EXPECT_EQ(gfx::Rect(600, 0, 300, 252).ToString(), |
| 152 maximized->GetWindowBoundsInScreen().ToString()); | 152 maximized->GetWindowBoundsInScreen().ToString()); |
| 153 EXPECT_EQ(gfx::Rect(0, 0, 300, 252).ToString(), | 153 EXPECT_EQ(gfx::Rect(0, 0, 300, 252).ToString(), |
| 154 maximized->GetNativeView()->GetBoundsInRootWindow().ToString()); | 154 maximized->GetNativeView()->GetBoundsInRootWindow().ToString()); |
| 155 | 155 |
| 156 views::Widget* minimized = CreateTestWidget(gfx::Rect(800, 10, 100, 100)); | 156 views::Widget* minimized = CreateTestWidget(gfx::Rect(550, 10, 200, 200)); |
| 157 minimized->Minimize(); | 157 minimized->Minimize(); |
| 158 EXPECT_EQ(root_windows[1], minimized->GetNativeView()->GetRootWindow()); | 158 EXPECT_EQ(root_windows[1], minimized->GetNativeView()->GetRootWindow()); |
| 159 EXPECT_EQ("800,10 100x100", minimized->GetWindowBoundsInScreen().ToString()); | 159 EXPECT_EQ("550,10 200x200", minimized->GetWindowBoundsInScreen().ToString()); |
| 160 | 160 |
| 161 views::Widget* fullscreen = CreateTestWidget(gfx::Rect(850, 10, 100, 100)); | 161 views::Widget* fullscreen = CreateTestWidget(gfx::Rect(850, 10, 200, 200)); |
| 162 display::Display secondary_display = | |
| 163 Shell::GetInstance()->display_manager()->GetSecondaryDisplay(); | |
| 164 gfx::Rect orig_bounds = fullscreen->GetWindowBoundsInScreen(); | |
| 165 EXPECT_TRUE(secondary_display.work_area().Intersects(orig_bounds)); | |
| 166 EXPECT_FALSE(secondary_display.work_area().Contains(orig_bounds)); | |
| 167 | |
| 162 fullscreen->SetFullscreen(true); | 168 fullscreen->SetFullscreen(true); |
| 163 EXPECT_EQ(root_windows[1], fullscreen->GetNativeView()->GetRootWindow()); | 169 EXPECT_EQ(root_windows[1], fullscreen->GetNativeView()->GetRootWindow()); |
| 164 | 170 |
| 165 EXPECT_EQ("600,0 300x300", fullscreen->GetWindowBoundsInScreen().ToString()); | 171 EXPECT_EQ("600,0 300x300", fullscreen->GetWindowBoundsInScreen().ToString()); |
| 166 EXPECT_EQ("0,0 300x300", | 172 EXPECT_EQ("0,0 300x300", |
| 167 fullscreen->GetNativeView()->GetBoundsInRootWindow().ToString()); | 173 fullscreen->GetNativeView()->GetBoundsInRootWindow().ToString()); |
| 168 | 174 |
| 175 EXPECT_EQ("600,0 300x300", fullscreen->GetWindowBoundsInScreen().ToString()); | |
| 176 EXPECT_EQ("0,0 300x300", | |
| 177 fullscreen->GetNativeView()->GetBoundsInRootWindow().ToString()); | |
|
afakhry
2017/02/21 17:42:51
These EXPECT_EQ()s seem to be the exact same as th
oshima
2017/02/21 23:54:55
oops, not sure why I added. removed.
| |
| 178 | |
| 169 views::Widget* unparented_control = new Widget; | 179 views::Widget* unparented_control = new Widget; |
| 170 Widget::InitParams params; | 180 Widget::InitParams params; |
| 171 params.bounds = gfx::Rect(650, 10, 100, 100); | 181 params.bounds = gfx::Rect(650, 10, 100, 100); |
| 172 params.context = CurrentContext(); | 182 params.context = CurrentContext(); |
| 173 params.type = Widget::InitParams::TYPE_CONTROL; | 183 params.type = Widget::InitParams::TYPE_CONTROL; |
| 174 unparented_control->Init(params); | 184 unparented_control->Init(params); |
| 175 EXPECT_EQ(root_windows[1], | 185 EXPECT_EQ(root_windows[1], |
| 176 unparented_control->GetNativeView()->GetRootWindow()); | 186 unparented_control->GetNativeView()->GetRootWindow()); |
| 177 EXPECT_EQ(kShellWindowId_UnparentedControlContainer, | 187 EXPECT_EQ(kShellWindowId_UnparentedControlContainer, |
| 178 unparented_control->GetNativeView()->parent()->id()); | 188 unparented_control->GetNativeView()->parent()->id()); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 217 // Set fullscreen to true, but maximized window's size won't change because | 227 // Set fullscreen to true, but maximized window's size won't change because |
| 218 // it's not visible. see crbug.com/504299. | 228 // it's not visible. see crbug.com/504299. |
| 219 fullscreen->SetFullscreen(true); | 229 fullscreen->SetFullscreen(true); |
| 220 EXPECT_EQ(root_windows[0], maximized->GetNativeView()->GetRootWindow()); | 230 EXPECT_EQ(root_windows[0], maximized->GetNativeView()->GetRootWindow()); |
| 221 EXPECT_EQ(gfx::Rect(0, 0, 600, 552).ToString(), | 231 EXPECT_EQ(gfx::Rect(0, 0, 600, 552).ToString(), |
| 222 maximized->GetWindowBoundsInScreen().ToString()); | 232 maximized->GetWindowBoundsInScreen().ToString()); |
| 223 EXPECT_EQ(gfx::Rect(0, 0, 600, 552).ToString(), | 233 EXPECT_EQ(gfx::Rect(0, 0, 600, 552).ToString(), |
| 224 maximized->GetNativeView()->GetBoundsInRootWindow().ToString()); | 234 maximized->GetNativeView()->GetBoundsInRootWindow().ToString()); |
| 225 | 235 |
| 226 EXPECT_EQ(root_windows[0], minimized->GetNativeView()->GetRootWindow()); | 236 EXPECT_EQ(root_windows[0], minimized->GetNativeView()->GetRootWindow()); |
| 227 EXPECT_EQ("400,20 100x100", minimized->GetWindowBoundsInScreen().ToString()); | 237 EXPECT_EQ("0,20 200x200", minimized->GetWindowBoundsInScreen().ToString()); |
| 228 | 238 |
| 229 EXPECT_EQ(root_windows[0], fullscreen->GetNativeView()->GetRootWindow()); | 239 EXPECT_EQ(root_windows[0], fullscreen->GetNativeView()->GetRootWindow()); |
| 230 EXPECT_TRUE(fullscreen->IsFullscreen()); | 240 EXPECT_TRUE(fullscreen->IsFullscreen()); |
| 231 EXPECT_EQ("0,0 600x600", fullscreen->GetWindowBoundsInScreen().ToString()); | 241 EXPECT_EQ("0,0 600x600", fullscreen->GetWindowBoundsInScreen().ToString()); |
| 232 EXPECT_EQ("0,0 600x600", | 242 EXPECT_EQ("0,0 600x600", |
| 233 fullscreen->GetNativeView()->GetBoundsInRootWindow().ToString()); | 243 fullscreen->GetNativeView()->GetBoundsInRootWindow().ToString()); |
| 234 | 244 |
| 235 // Test if the restore bounds are correctly updated. | 245 // Test if the restore bounds are correctly updated. |
| 236 wm::GetWindowState(maximized->GetNativeView())->Restore(); | 246 wm::GetWindowState(maximized->GetNativeView())->Restore(); |
| 237 EXPECT_EQ("200,20 100x100", maximized->GetWindowBoundsInScreen().ToString()); | 247 EXPECT_EQ("200,20 100x100", maximized->GetWindowBoundsInScreen().ToString()); |
| 238 EXPECT_EQ("200,20 100x100", | 248 EXPECT_EQ("200,20 100x100", |
| 239 maximized->GetNativeView()->GetBoundsInRootWindow().ToString()); | 249 maximized->GetNativeView()->GetBoundsInRootWindow().ToString()); |
| 240 | 250 |
| 241 fullscreen->SetFullscreen(false); | 251 fullscreen->SetFullscreen(false); |
| 242 EXPECT_EQ("500,20 100x100", fullscreen->GetWindowBoundsInScreen().ToString()); | 252 EXPECT_EQ("400,20 200x200", fullscreen->GetWindowBoundsInScreen().ToString()); |
| 243 EXPECT_EQ("500,20 100x100", | 253 EXPECT_EQ("400,20 200x200", |
| 244 fullscreen->GetNativeView()->GetBoundsInRootWindow().ToString()); | 254 fullscreen->GetNativeView()->GetBoundsInRootWindow().ToString()); |
| 245 | 255 |
| 246 // Test if the unparented widget has moved. | 256 // Test if the unparented widget has moved. |
| 247 EXPECT_EQ(root_windows[0], | 257 EXPECT_EQ(root_windows[0], |
| 248 unparented_control->GetNativeView()->GetRootWindow()); | 258 unparented_control->GetNativeView()->GetRootWindow()); |
| 249 EXPECT_EQ(kShellWindowId_UnparentedControlContainer, | 259 EXPECT_EQ(kShellWindowId_UnparentedControlContainer, |
| 250 unparented_control->GetNativeView()->parent()->id()); | 260 unparented_control->GetNativeView()->parent()->id()); |
| 251 | 261 |
| 252 // Test if the panel has moved. | 262 // Test if the panel has moved. |
| 253 EXPECT_EQ(root_windows[0], panel->GetRootWindow()); | 263 EXPECT_EQ(root_windows[0], panel->GetRootWindow()); |
| (...skipping 950 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1204 keyboard_controller->ui()->GetKeyboardWindow()->SetBounds( | 1214 keyboard_controller->ui()->GetKeyboardWindow()->SetBounds( |
| 1205 gfx::Rect(0, 400, 800, 200)); | 1215 gfx::Rect(0, 400, 800, 200)); |
| 1206 EXPECT_EQ("0,400 800x200", keyboard_container->bounds().ToString()); | 1216 EXPECT_EQ("0,400 800x200", keyboard_container->bounds().ToString()); |
| 1207 | 1217 |
| 1208 UpdateDisplay("600x800"); | 1218 UpdateDisplay("600x800"); |
| 1209 EXPECT_EQ("0,600 600x200", keyboard_container->bounds().ToString()); | 1219 EXPECT_EQ("0,600 600x200", keyboard_container->bounds().ToString()); |
| 1210 } | 1220 } |
| 1211 | 1221 |
| 1212 } // namespace test | 1222 } // namespace test |
| 1213 } // namespace ash | 1223 } // namespace ash |
| OLD | NEW |