Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(57)

Side by Side Diff: chrome/browser/apps/app_window_interactive_uitest.cc

Issue 405323002: [Win Aero] Correctly set the minimum window size. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync and rebase Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/ui/views/apps/app_window_desktop_window_tree_host_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "apps/ui/native_app_window.h" 5 #include "apps/ui/native_app_window.h"
6 #include "chrome/browser/apps/app_browsertest_util.h" 6 #include "chrome/browser/apps/app_browsertest_util.h"
7 #include "chrome/browser/extensions/extension_test_message_listener.h" 7 #include "chrome/browser/extensions/extension_test_message_listener.h"
8 #include "chrome/test/base/interactive_test_utils.h" 8 #include "chrome/test/base/interactive_test_utils.h"
9 9
10 #if defined(OS_MACOSX) && !defined(OS_IOS) 10 #if defined(OS_MACOSX) && !defined(OS_IOS)
11 #include "base/mac/mac_util.h" 11 #include "base/mac/mac_util.h"
12 #endif 12 #endif
13 13
14 #if defined(OS_WIN)
15 #include <windows.h>
16 #include "ui/aura/window.h"
17 #include "ui/aura/window_tree_host.h"
18 #include "ui/views/widget/desktop_aura/desktop_window_tree_host_win.h"
19 #include "ui/views/win/hwnd_message_handler_delegate.h"
20 #include "ui/views/win/hwnd_util.h"
21 #endif
22
14 using apps::NativeAppWindow; 23 using apps::NativeAppWindow;
15 24
16 // Helper class that has to be created in the stack to check if the fullscreen 25 // Helper class that has to be created in the stack to check if the fullscreen
17 // setting of a NativeWindow has changed since the creation of the object. 26 // setting of a NativeWindow has changed since the creation of the object.
18 class FullscreenChangeWaiter { 27 class FullscreenChangeWaiter {
19 public: 28 public:
20 explicit FullscreenChangeWaiter(NativeAppWindow* window) 29 explicit FullscreenChangeWaiter(NativeAppWindow* window)
21 : window_(window), 30 : window_(window),
22 initial_fullscreen_state_(window_->IsFullscreen()) {} 31 initial_fullscreen_state_(window_->IsFullscreen()) {}
23 32
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 71
63 // This method will wait until the application is able to ack a key event. 72 // This method will wait until the application is able to ack a key event.
64 void WaitUntilKeyFocus() { 73 void WaitUntilKeyFocus() {
65 ExtensionTestMessageListener key_listener("KeyReceived", false); 74 ExtensionTestMessageListener key_listener("KeyReceived", false);
66 75
67 while (!key_listener.was_satisfied()) { 76 while (!key_listener.was_satisfied()) {
68 ASSERT_TRUE(SimulateKeyPress(ui::VKEY_Z)); 77 ASSERT_TRUE(SimulateKeyPress(ui::VKEY_Z));
69 content::RunAllPendingInMessageLoop(); 78 content::RunAllPendingInMessageLoop();
70 } 79 }
71 } 80 }
81
82 // This test is a method so that we can test with each frame type.
83 void TestOuterBoundsHelper(const std::string& frame_type);
72 }; 84 };
73 85
74 IN_PROC_BROWSER_TEST_F(AppWindowInteractiveTest, ESCLeavesFullscreenWindow) { 86 IN_PROC_BROWSER_TEST_F(AppWindowInteractiveTest, ESCLeavesFullscreenWindow) {
75 // This test is flaky on MacOS 10.6. 87 // This test is flaky on MacOS 10.6.
76 #if defined(OS_MACOSX) && !defined(OS_IOS) 88 #if defined(OS_MACOSX) && !defined(OS_IOS)
77 if (base::mac::IsOSSnowLeopard()) 89 if (base::mac::IsOSSnowLeopard())
78 return; 90 return;
79 #endif 91 #endif
80 92
81 ExtensionTestMessageListener launched_listener("Launched", true); 93 ExtensionTestMessageListener launched_listener("Launched", true);
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 323
312 ASSERT_TRUE(second_key_listener.WaitUntilSatisfied()); 324 ASSERT_TRUE(second_key_listener.WaitUntilSatisfied());
313 325
314 // We assume that at that point, if we had to leave fullscreen, we should be. 326 // We assume that at that point, if we had to leave fullscreen, we should be.
315 // However, by nature, we can not guarantee that and given that we do test 327 // However, by nature, we can not guarantee that and given that we do test
316 // that nothing happens, we might end up with random-success when the feature 328 // that nothing happens, we might end up with random-success when the feature
317 // is broken. 329 // is broken.
318 EXPECT_TRUE(GetFirstAppWindow()->GetBaseWindow()->IsFullscreen()); 330 EXPECT_TRUE(GetFirstAppWindow()->GetBaseWindow()->IsFullscreen());
319 } 331 }
320 332
333 IN_PROC_BROWSER_TEST_F(AppWindowInteractiveTest, TestInnerBounds) {
334 ASSERT_TRUE(RunAppWindowInteractiveTest("testInnerBounds")) << message_;
335 }
336
337 void AppWindowInteractiveTest::TestOuterBoundsHelper(
338 const std::string& frame_type) {
339 ExtensionTestMessageListener launched_listener("Launched", true);
340 const extensions::Extension* app =
341 LoadAndLaunchPlatformApp("outer_bounds", &launched_listener);
342
343 launched_listener.Reply(frame_type);
344 launched_listener.Reset();
345 ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
346
347 apps::AppWindow* window = GetFirstAppWindowForApp(app->id());
348 gfx::Rect window_bounds;
349 gfx::Size min_size, max_size;
350
351 #if defined(OS_WIN)
352 // Get the bounds from the HWND.
353 HWND hwnd = views::HWNDForNativeWindow(window->GetNativeWindow());
354 RECT rect;
355 ::GetWindowRect(hwnd, &rect);
356 window_bounds = gfx::Rect(
357 rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top);
358
359 // HWNDMessageHandler calls this when responding to WM_GETMINMAXSIZE, so it's
360 // the closest to what the window will see.
361 views::HWNDMessageHandlerDelegate* host =
362 static_cast<views::HWNDMessageHandlerDelegate*>(
363 static_cast<views::DesktopWindowTreeHostWin*>(
364 aura::WindowTreeHost::GetForAcceleratedWidget(hwnd)));
365 host->GetMinMaxSize(&min_size, &max_size);
366 // Note that this does not include the the client area insets so we need to
367 // add them.
368 gfx::Insets insets;
369 host->GetClientAreaInsets(&insets);
370 min_size = gfx::Size(min_size.width() + insets.left() + insets.right(),
371 min_size.height() + insets.top() + insets.bottom());
372 max_size = gfx::Size(
373 max_size.width() ? max_size.width() + insets.left() + insets.right() : 0,
374 max_size.height() ? max_size.height() + insets.top() + insets.bottom()
375 : 0);
376 #endif // defined(OS_WIN)
377
378 // These match the values in the outer_bounds/test.js
379 EXPECT_EQ(gfx::Rect(10, 11, 300, 301), window_bounds);
380 EXPECT_EQ(window->GetBaseWindow()->GetBounds(), window_bounds);
381 EXPECT_EQ(200, min_size.width());
382 EXPECT_EQ(201, min_size.height());
383 EXPECT_EQ(400, max_size.width());
384 EXPECT_EQ(401, max_size.height());
385 }
386
387 // TODO(jackhou): Make this test work for other OSes.
388 #if !defined(OS_WIN)
389 #define MAYBE_TestOuterBoundsFrameChrome DISABLED_TestOuterBoundsFrameChrome
390 #define MAYBE_TestOuterBoundsFrameNone DISABLED_TestOuterBoundsFrameNone
391 #define MAYBE_TestOuterBoundsFrameColor DISABLED_TestOuterBoundsFrameColor
392 #else
393 #define MAYBE_TestOuterBoundsFrameChrome TestOuterBoundsFrameChrome
394 #define MAYBE_TestOuterBoundsFrameNone TestOuterBoundsFrameNone
395 #define MAYBE_TestOuterBoundsFrameColor TestOuterBoundsFrameColor
396 #endif
397
398 // Test that the outer bounds match that of the native window.
399 IN_PROC_BROWSER_TEST_F(AppWindowInteractiveTest,
400 MAYBE_TestOuterBoundsFrameChrome) {
401 TestOuterBoundsHelper("chrome");
402 }
403 IN_PROC_BROWSER_TEST_F(AppWindowInteractiveTest,
404 MAYBE_TestOuterBoundsFrameNone) {
405 TestOuterBoundsHelper("none");
406 }
407 IN_PROC_BROWSER_TEST_F(AppWindowInteractiveTest,
408 MAYBE_TestOuterBoundsFrameColor) {
409 TestOuterBoundsHelper("color");
410 }
411
321 // This test does not work on Linux Aura because ShowInactive() is not 412 // This test does not work on Linux Aura because ShowInactive() is not
322 // implemented. See http://crbug.com/325142 413 // implemented. See http://crbug.com/325142
323 // It also does not work on Windows because of the document being focused even 414 // It also does not work on Windows because of the document being focused even
324 // though the window is not activated. See http://crbug.com/326986 415 // though the window is not activated. See http://crbug.com/326986
325 // It also does not work on MacOS because ::ShowInactive() ends up behaving like 416 // It also does not work on MacOS because ::ShowInactive() ends up behaving like
326 // ::Show() because of Cocoa conventions. See http://crbug.com/326987 417 // ::Show() because of Cocoa conventions. See http://crbug.com/326987
327 // Those tests should be disabled on Linux GTK when they are enabled on the 418 // Those tests should be disabled on Linux GTK when they are enabled on the
328 // other platforms, see http://crbug.com/328829 419 // other platforms, see http://crbug.com/328829
329 #if (defined(OS_LINUX) && defined(USE_AURA)) || \ 420 #if (defined(OS_LINUX) && defined(USE_AURA)) || \
330 defined(OS_WIN) || defined(OS_MACOSX) 421 defined(OS_WIN) || defined(OS_MACOSX)
331 #define MAYBE_TestCreate DISABLED_TestCreate 422 #define MAYBE_TestCreate DISABLED_TestCreate
332 #define MAYBE_TestShow DISABLED_TestShow 423 #define MAYBE_TestShow DISABLED_TestShow
333 #else 424 #else
334 #define MAYBE_TestCreate TestCreate 425 #define MAYBE_TestCreate TestCreate
335 #define MAYBE_TestShow TestShow 426 #define MAYBE_TestShow TestShow
336 #endif 427 #endif
337 428
338 IN_PROC_BROWSER_TEST_F(AppWindowInteractiveTest, MAYBE_TestCreate) { 429 IN_PROC_BROWSER_TEST_F(AppWindowInteractiveTest, MAYBE_TestCreate) {
339 ASSERT_TRUE(RunAppWindowInteractiveTest("testCreate")) << message_; 430 ASSERT_TRUE(RunAppWindowInteractiveTest("testCreate")) << message_;
340 } 431 }
341 432
342 IN_PROC_BROWSER_TEST_F(AppWindowInteractiveTest, MAYBE_TestShow) { 433 IN_PROC_BROWSER_TEST_F(AppWindowInteractiveTest, MAYBE_TestShow) {
343 ASSERT_TRUE(RunAppWindowInteractiveTest("testShow")) << message_; 434 ASSERT_TRUE(RunAppWindowInteractiveTest("testShow")) << message_;
344 } 435 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/views/apps/app_window_desktop_window_tree_host_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698