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

Unified Diff: chrome/browser/ui/browser_browsertest.cc

Issue 2690563005: cros: Disable the auto management logic for v1app browser window (Closed)
Patch Set: based on ps3's comments Created 3 years, 10 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
« no previous file with comments | « no previous file | chrome/browser/ui/views/frame/browser_frame_ash.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/browser_browsertest.cc
diff --git a/chrome/browser/ui/browser_browsertest.cc b/chrome/browser/ui/browser_browsertest.cc
index d35e8938bb307b618adace55fe91a652723aab53..7fd46bf314733b5bc9ab966dd124b96b54ceb31a 100644
--- a/chrome/browser/ui/browser_browsertest.cc
+++ b/chrome/browser/ui/browser_browsertest.cc
@@ -124,6 +124,12 @@
#include "chrome/browser/browser_process.h"
#endif
+#if defined(OS_CHROMEOS)
+#include "ui/aura/window.h"
+#include "ui/display/display.h"
+#include "ui/display/screen.h"
+#endif
+
using app_modal::AppModalDialog;
using app_modal::AppModalDialogQueue;
using app_modal::JavaScriptAppModalDialog;
@@ -2942,3 +2948,67 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, TestPopupBounds) {
browser->window()->Close();
}
}
+
+#if defined(OS_CHROMEOS)
+namespace {
+
+class BrowserTestParam : public InProcessBrowserTest,
+ public testing::WithParamInterface<bool> {
+ public:
+ bool TestApp() { return GetParam(); }
+};
+
+} // namespace
+
+// Test that in Chrome OS, for app browser (v1app) windows, the auto management
sky 2017/02/13 23:35:51 We try to avoid platform specific code in c/b/ui.
Qiang(Joe) Xu 2017/02/14 00:00:20 sure, updated.
+// logic is disabled while for tabbed browser windows, it is enabled.
+IN_PROC_BROWSER_TEST_P(BrowserTestParam,
+ TabbedOrAppBrowserWindowAutoManagementTest) {
+ // Default |browser()| is not used by this test.
+ browser()->window()->Close();
+
+ // Open a new browser window (app or tabbed depending on a parameter).
+ bool test_app = TestApp();
+ Browser::CreateParams params =
+ test_app ? Browser::CreateParams::CreateForApp(
+ "test_browser_app", true /* trusted_source */, gfx::Rect(),
+ browser()->profile())
+ : Browser::CreateParams(browser()->profile());
+ params.initial_show_state = ui::SHOW_STATE_DEFAULT;
+ Browser* browser = new Browser(params);
+ gfx::NativeWindow window = browser->window()->GetNativeWindow();
+ gfx::Rect original_bounds(gfx::Rect(150, 250, 400, 100));
+ window->SetBounds(original_bounds);
+ window->Show();
+
+ // For tabbed browser window, it will be centered to work area by auto window
+ // mangement logic; for app browser window, it will remain the given bounds.
+ gfx::Rect work_area = display::Screen::GetScreen()
+ ->GetDisplayNearestPoint(window->bounds().origin())
+ .work_area();
+ gfx::Rect tabbed_expected_bounds = work_area;
+ tabbed_expected_bounds.ClampToCenteredSize(original_bounds.size());
+ tabbed_expected_bounds.set_y(original_bounds.y());
+ if (test_app)
+ EXPECT_EQ(original_bounds.ToString(), window->bounds().ToString());
+ else
+ EXPECT_EQ(tabbed_expected_bounds.ToString(), window->bounds().ToString());
+
+ // Close the browser and re-create the browser window with the same app name.
+ browser->window()->Close();
+ browser = new Browser(params);
+ browser->window()->Show();
+
+ // The newly created browser window should remain the same bounds for each.
+ window = browser->window()->GetNativeWindow();
+ if (test_app)
+ EXPECT_EQ(original_bounds.ToString(), window->bounds().ToString());
+ else
+ EXPECT_EQ(tabbed_expected_bounds.ToString(), window->bounds().ToString());
+}
+
+INSTANTIATE_TEST_CASE_P(BrowserTestTabbedOrApp,
+ BrowserTestParam,
+ testing::Bool());
+
+#endif // defined(OS_CHROMEOS)
« no previous file with comments | « no previous file | chrome/browser/ui/views/frame/browser_frame_ash.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698