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

Unified 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: Add outer bounds test. Actually fix this. 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/apps/app_window_interactive_uitest.cc
diff --git a/chrome/browser/apps/app_window_interactive_uitest.cc b/chrome/browser/apps/app_window_interactive_uitest.cc
index c7bfa9164d2b8c8f7c65dadb7a1514ce3b7aef2e..0290ad5d25b993c7af9c5760cf8b1aff63c24aac 100644
--- a/chrome/browser/apps/app_window_interactive_uitest.cc
+++ b/chrome/browser/apps/app_window_interactive_uitest.cc
@@ -11,6 +11,15 @@
#include "base/mac/mac_util.h"
#endif
+#if defined(OS_WIN)
+#include <windows.h>
+#include "ui/aura/window.h"
+#include "ui/aura/window_tree_host.h"
+#include "ui/views/widget/desktop_aura/desktop_window_tree_host_win.h"
+#include "ui/views/win/hwnd_message_handler_delegate.h"
+#include "ui/views/win/hwnd_util.h"
+#endif
+
using apps::NativeAppWindow;
// Helper class that has to be created in the stack to check if the fullscreen
@@ -318,6 +327,63 @@ IN_PROC_BROWSER_TEST_F(AppWindowInteractiveTest,
EXPECT_TRUE(GetFirstAppWindow()->GetBaseWindow()->IsFullscreen());
}
+IN_PROC_BROWSER_TEST_F(AppWindowInteractiveTest, TestInnerBounds) {
+ ASSERT_TRUE(RunAppWindowInteractiveTest("testInnerBounds")) << message_;
+}
+
+// TODO(jackhou): Make this test work for other OSes.
+#if !defined(OS_WIN)
+#define MAYBE_TestOuterBounds DISABLED_TestOuterBounds
+#else
+#define MAYBE_TestOuterBounds TestOuterBounds
+#endif
+
+// Test that the outer bounds match that of the native window.
+IN_PROC_BROWSER_TEST_F(AppWindowInteractiveTest, MAYBE_TestOuterBounds) {
+ ExtensionTestMessageListener launched_listener("Launched", true);
benwells 2014/08/12 03:51:40 Nit: You don't need this listener. Just call LoadA
jackhou1 2014/08/12 06:12:07 Done.
+ const extensions::Extension* app =
+ LoadAndLaunchPlatformApp("outer_bounds", &launched_listener);
+
+ apps::AppWindow* window = GetFirstAppWindowForApp(app->id());
+ gfx::Rect window_bounds;
+ gfx::Size min_size, max_size;
+
+#if defined(OS_WIN)
+ // Get the bounds from the HWND.
+ HWND hwnd = views::HWNDForNativeWindow(window->GetNativeWindow());
+ RECT rect;
+ ::GetWindowRect(hwnd, &rect);
+ window_bounds = gfx::Rect(
+ rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top);
+
+ // HWNDMessageHandler calls this when responding to WM_GETMINMAXSIZE, so it's
+ // the closest to what the window will see.
+ views::HWNDMessageHandlerDelegate* host =
+ static_cast<views::HWNDMessageHandlerDelegate*>(
+ static_cast<views::DesktopWindowTreeHostWin*>(
+ aura::WindowTreeHost::GetForAcceleratedWidget(hwnd)));
+ host->GetMinMaxSize(&min_size, &max_size);
+ // Note that this does not include the the client area insets so we need to
+ // add them.
+ gfx::Insets insets;
+ host->GetClientAreaInsets(&insets);
+ min_size = gfx::Size(min_size.width() + insets.left() + insets.right(),
+ min_size.height() + insets.top() + insets.bottom());
+ max_size = gfx::Size(
+ max_size.width() ? max_size.width() + insets.left() + insets.right() : 0,
+ max_size.height() ? max_size.height() + insets.top() + insets.bottom()
+ : 0);
+#endif // defined(OS_WIN)
+
+ // These match the values in the outer_bounds/test.js
+ EXPECT_EQ(gfx::Rect(10, 11, 300, 301), window_bounds);
+ EXPECT_EQ(window->GetBaseWindow()->GetBounds(), window_bounds);
+ EXPECT_EQ(200, min_size.width());
+ EXPECT_EQ(201, min_size.height());
+ EXPECT_EQ(400, max_size.width());
+ EXPECT_EQ(401, max_size.height());
+}
+
// This test does not work on Linux Aura because ShowInactive() is not
// implemented. See http://crbug.com/325142
// It also does not work on Windows because of the document being focused even

Powered by Google App Engine
This is Rietveld 408576698