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 <algorithm> | 5 #include <algorithm> |
| 6 #include <set> | 6 #include <set> |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 34 #if defined(OS_WIN) | 34 #if defined(OS_WIN) |
| 35 #include "ui/aura/window.h" | 35 #include "ui/aura/window.h" |
| 36 #include "ui/aura/window_tree_host.h" | 36 #include "ui/aura/window_tree_host.h" |
| 37 #include "ui/base/view_prop.h" | 37 #include "ui/base/view_prop.h" |
| 38 #include "ui/base/win/window_event_target.h" | 38 #include "ui/base/win/window_event_target.h" |
| 39 #include "ui/views/win/hwnd_util.h" | 39 #include "ui/views/win/hwnd_util.h" |
| 40 #endif | 40 #endif |
| 41 | 41 |
| 42 #if defined(OS_MACOSX) | 42 #if defined(OS_MACOSX) |
| 43 #include "base/mac/mac_util.h" | 43 #include "base/mac/mac_util.h" |
| 44 #include "ui/base/test/scoped_fake_nswindow_fullscreen.h" | |
| 44 #endif | 45 #endif |
| 45 | 46 |
| 46 namespace views { | 47 namespace views { |
| 47 namespace test { | 48 namespace test { |
| 48 | 49 |
| 49 namespace { | 50 namespace { |
| 50 | 51 |
| 51 // TODO(tdanderson): This utility function is used in different unittest | 52 // TODO(tdanderson): This utility function is used in different unittest |
| 52 // files. Move to a common location to avoid | 53 // files. Move to a common location to avoid |
| 53 // repeated code. | 54 // repeated code. |
| (...skipping 1220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1274 widget->GetClientAreaBoundsInScreen().ToString()); | 1275 widget->GetClientAreaBoundsInScreen().ToString()); |
| 1275 | 1276 |
| 1276 // Verify origin is stable for a frameless window as well. | 1277 // Verify origin is stable for a frameless window as well. |
| 1277 widget->SetSize(kTestSize); | 1278 widget->SetSize(kTestSize); |
| 1278 EXPECT_EQ(kTestBounds.origin().ToString(), | 1279 EXPECT_EQ(kTestBounds.origin().ToString(), |
| 1279 widget->GetWindowBoundsInScreen().origin().ToString()); | 1280 widget->GetWindowBoundsInScreen().origin().ToString()); |
| 1280 | 1281 |
| 1281 widget->CloseNow(); | 1282 widget->CloseNow(); |
| 1282 } | 1283 } |
| 1283 | 1284 |
| 1284 // Before being enabled on Mac, this was #ifdef(false). | 1285 // Non-Desktop widgets need the shell to maximize/fullscreen window. |
| 1285 // TODO(tapted): Fix this for DesktopNativeWidgets on other platforms. | 1286 // Disable on Linux because windows restore to the wrong bounds. |
| 1287 // See http://crbug.com/515369. | |
| 1288 #if !defined(OS_CHROMEOS) && !defined(OS_LINUX) | |
|
tapted
2015/07/30 06:50:18
I think we can do the MAYBE_GetRestoredbounds thin
jackhou1
2015/07/30 07:25:03
Done.
| |
| 1289 TEST_F(WidgetTest, GetRestoredBounds) { | |
| 1286 #if defined(OS_MACOSX) | 1290 #if defined(OS_MACOSX) |
| 1287 // Aura needs shell to maximize/fullscreen window. | 1291 ui::test::ScopedFakeNSWindowFullscreen fake_fullscreen; |
|
tapted
2015/07/30 06:50:18
nit: comment here like
// Fullscreen on Mac requi
jackhou1
2015/07/30 07:25:03
Done.
| |
| 1288 // NativeWidgetGtk doesn't implement GetRestoredBounds. | 1292 #endif |
| 1289 TEST_F(WidgetTest, GetRestoredBounds) { | 1293 |
| 1290 Widget* toplevel = CreateTopLevelPlatformWidget(); | 1294 Widget* toplevel = CreateNativeDesktopWidget(); |
| 1291 EXPECT_EQ(toplevel->GetWindowBoundsInScreen().ToString(), | |
| 1292 toplevel->GetRestoredBounds().ToString()); | |
| 1293 toplevel->Show(); | 1295 toplevel->Show(); |
| 1296 // Initial restored bounds have non-zero size. | |
| 1297 EXPECT_GT(toplevel->GetRestoredBounds().width(), 0); | |
|
tapted
2015/07/30 06:50:18
nit: EXPECT_FALSE(toplevel->GetRestoredBounds().Is
jackhou1
2015/07/30 07:25:04
Done.
| |
| 1298 EXPECT_GT(toplevel->GetRestoredBounds().height(), 0); | |
| 1299 | |
| 1300 gfx::Rect bounds(100, 100, 200, 200); | |
|
tapted
2015/07/30 06:50:18
nit: const?
jackhou1
2015/07/30 07:25:04
Done.
| |
| 1301 toplevel->SetBounds(bounds); | |
| 1302 EXPECT_EQ(bounds, toplevel->GetWindowBoundsInScreen()); | |
| 1303 EXPECT_EQ(bounds, toplevel->GetRestoredBounds()); | |
| 1304 | |
| 1294 toplevel->Maximize(); | 1305 toplevel->Maximize(); |
| 1295 RunPendingMessages(); | 1306 RunPendingMessages(); |
| 1296 #if defined(OS_MACOSX) | 1307 #if defined(OS_MACOSX) |
| 1297 // Current expectation on Mac is to do nothing on Maximize. | 1308 // Current expectation on Mac is to do nothing on Maximize. |
| 1298 EXPECT_EQ(toplevel->GetWindowBoundsInScreen().ToString(), | 1309 EXPECT_EQ(toplevel->GetWindowBoundsInScreen(), toplevel->GetRestoredBounds()); |
| 1299 toplevel->GetRestoredBounds().ToString()); | |
| 1300 #else | 1310 #else |
| 1301 EXPECT_NE(toplevel->GetWindowBoundsInScreen().ToString(), | 1311 EXPECT_NE(toplevel->GetWindowBoundsInScreen(), toplevel->GetRestoredBounds()); |
| 1302 toplevel->GetRestoredBounds().ToString()); | |
| 1303 #endif | 1312 #endif |
| 1304 EXPECT_GT(toplevel->GetRestoredBounds().width(), 0); | 1313 EXPECT_EQ(bounds, toplevel->GetRestoredBounds()); |
| 1305 EXPECT_GT(toplevel->GetRestoredBounds().height(), 0); | |
| 1306 | 1314 |
| 1307 toplevel->Restore(); | 1315 toplevel->Restore(); |
| 1308 RunPendingMessages(); | 1316 RunPendingMessages(); |
| 1309 EXPECT_EQ(toplevel->GetWindowBoundsInScreen().ToString(), | 1317 EXPECT_EQ(bounds, toplevel->GetWindowBoundsInScreen()); |
| 1310 toplevel->GetRestoredBounds().ToString()); | 1318 EXPECT_EQ(bounds, toplevel->GetRestoredBounds()); |
| 1311 | 1319 |
| 1312 toplevel->SetFullscreen(true); | 1320 toplevel->SetFullscreen(true); |
| 1313 RunPendingMessages(); | 1321 RunPendingMessages(); |
| 1314 | 1322 |
| 1315 if (IsTestingSnowLeopard()) { | 1323 if (IsTestingSnowLeopard()) { |
| 1316 // Fullscreen not implemented for Snow Leopard. | 1324 // Fullscreen not implemented for Snow Leopard. |
| 1317 EXPECT_EQ(toplevel->GetWindowBoundsInScreen().ToString(), | 1325 EXPECT_EQ(toplevel->GetWindowBoundsInScreen(), |
| 1318 toplevel->GetRestoredBounds().ToString()); | 1326 toplevel->GetRestoredBounds()); |
| 1319 } else { | 1327 } else { |
| 1320 EXPECT_NE(toplevel->GetWindowBoundsInScreen().ToString(), | 1328 EXPECT_NE(toplevel->GetWindowBoundsInScreen(), |
| 1321 toplevel->GetRestoredBounds().ToString()); | 1329 toplevel->GetRestoredBounds()); |
| 1322 } | 1330 } |
| 1323 EXPECT_GT(toplevel->GetRestoredBounds().width(), 0); | 1331 EXPECT_EQ(bounds, toplevel->GetRestoredBounds()); |
| 1324 EXPECT_GT(toplevel->GetRestoredBounds().height(), 0); | 1332 |
| 1333 toplevel->SetFullscreen(false); | |
| 1334 RunPendingMessages(); | |
| 1335 EXPECT_EQ(bounds, toplevel->GetWindowBoundsInScreen()); | |
| 1336 EXPECT_EQ(bounds, toplevel->GetRestoredBounds()); | |
| 1337 | |
| 1338 toplevel->CloseNow(); | |
| 1325 } | 1339 } |
| 1326 #endif | 1340 #endif |
| 1327 | 1341 |
| 1328 // The key-event propagation from Widget happens differently on aura and | 1342 // The key-event propagation from Widget happens differently on aura and |
| 1329 // non-aura systems because of the difference in IME. So this test works only on | 1343 // non-aura systems because of the difference in IME. So this test works only on |
| 1330 // aura. | 1344 // aura. |
| 1331 TEST_F(WidgetTest, KeyboardInputEvent) { | 1345 TEST_F(WidgetTest, KeyboardInputEvent) { |
| 1332 Widget* toplevel = CreateTopLevelPlatformWidget(); | 1346 Widget* toplevel = CreateTopLevelPlatformWidget(); |
| 1333 View* container = toplevel->client_view(); | 1347 View* container = toplevel->client_view(); |
| 1334 | 1348 |
| (...skipping 2103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3438 EXPECT_FALSE(widget->IsAlwaysOnTop()); | 3452 EXPECT_FALSE(widget->IsAlwaysOnTop()); |
| 3439 widget->SetAlwaysOnTop(true); | 3453 widget->SetAlwaysOnTop(true); |
| 3440 EXPECT_TRUE(widget->IsAlwaysOnTop()); | 3454 EXPECT_TRUE(widget->IsAlwaysOnTop()); |
| 3441 widget->SetAlwaysOnTop(false); | 3455 widget->SetAlwaysOnTop(false); |
| 3442 EXPECT_FALSE(widget->IsAlwaysOnTop()); | 3456 EXPECT_FALSE(widget->IsAlwaysOnTop()); |
| 3443 widget->CloseNow(); | 3457 widget->CloseNow(); |
| 3444 } | 3458 } |
| 3445 | 3459 |
| 3446 } // namespace test | 3460 } // namespace test |
| 3447 } // namespace views | 3461 } // namespace views |
| OLD | NEW |