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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 "chrome/browser/ui/browser.h" 5 #include "chrome/browser/ui/browser.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 #if defined(OS_MACOSX) 117 #if defined(OS_MACOSX)
118 #include "base/mac/scoped_nsautorelease_pool.h" 118 #include "base/mac/scoped_nsautorelease_pool.h"
119 #include "chrome/browser/ui/cocoa/test/run_loop_testing.h" 119 #include "chrome/browser/ui/cocoa/test/run_loop_testing.h"
120 #endif 120 #endif
121 121
122 #if defined(OS_WIN) 122 #if defined(OS_WIN)
123 #include "base/i18n/rtl.h" 123 #include "base/i18n/rtl.h"
124 #include "chrome/browser/browser_process.h" 124 #include "chrome/browser/browser_process.h"
125 #endif 125 #endif
126 126
127 #if defined(OS_CHROMEOS)
128 #include "ui/aura/window.h"
129 #include "ui/display/display.h"
130 #include "ui/display/screen.h"
131 #endif
132
127 using app_modal::AppModalDialog; 133 using app_modal::AppModalDialog;
128 using app_modal::AppModalDialogQueue; 134 using app_modal::AppModalDialogQueue;
129 using app_modal::JavaScriptAppModalDialog; 135 using app_modal::JavaScriptAppModalDialog;
130 using base::ASCIIToUTF16; 136 using base::ASCIIToUTF16;
131 using content::InterstitialPage; 137 using content::InterstitialPage;
132 using content::HostZoomMap; 138 using content::HostZoomMap;
133 using content::NavigationController; 139 using content::NavigationController;
134 using content::NavigationEntry; 140 using content::NavigationEntry;
135 using content::OpenURLParams; 141 using content::OpenURLParams;
136 using content::Referrer; 142 using content::Referrer;
(...skipping 2798 matching lines...) Expand 10 before | Expand all | Expand 10 after
2935 Browser* browser = new Browser(params); 2941 Browser* browser = new Browser(params);
2936 gfx::Rect bounds = browser->window()->GetBounds(); 2942 gfx::Rect bounds = browser->window()->GetBounds();
2937 2943
2938 // Should be EXPECT_EQ, but this width is inconsistent across platforms. 2944 // Should be EXPECT_EQ, but this width is inconsistent across platforms.
2939 // See https://crbug.com/567925. 2945 // See https://crbug.com/567925.
2940 EXPECT_GE(bounds.width(), 100); 2946 EXPECT_GE(bounds.width(), 100);
2941 EXPECT_EQ(122, bounds.height()); 2947 EXPECT_EQ(122, bounds.height());
2942 browser->window()->Close(); 2948 browser->window()->Close();
2943 } 2949 }
2944 } 2950 }
2951
2952 #if defined(OS_CHROMEOS)
2953 namespace {
2954
2955 class BrowserTestParam : public InProcessBrowserTest,
2956 public testing::WithParamInterface<bool> {
2957 public:
2958 bool TestApp() { return GetParam(); }
2959 };
2960
2961 } // namespace
2962
2963 // 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.
2964 // logic is disabled while for tabbed browser windows, it is enabled.
2965 IN_PROC_BROWSER_TEST_P(BrowserTestParam,
2966 TabbedOrAppBrowserWindowAutoManagementTest) {
2967 // Default |browser()| is not used by this test.
2968 browser()->window()->Close();
2969
2970 // Open a new browser window (app or tabbed depending on a parameter).
2971 bool test_app = TestApp();
2972 Browser::CreateParams params =
2973 test_app ? Browser::CreateParams::CreateForApp(
2974 "test_browser_app", true /* trusted_source */, gfx::Rect(),
2975 browser()->profile())
2976 : Browser::CreateParams(browser()->profile());
2977 params.initial_show_state = ui::SHOW_STATE_DEFAULT;
2978 Browser* browser = new Browser(params);
2979 gfx::NativeWindow window = browser->window()->GetNativeWindow();
2980 gfx::Rect original_bounds(gfx::Rect(150, 250, 400, 100));
2981 window->SetBounds(original_bounds);
2982 window->Show();
2983
2984 // For tabbed browser window, it will be centered to work area by auto window
2985 // mangement logic; for app browser window, it will remain the given bounds.
2986 gfx::Rect work_area = display::Screen::GetScreen()
2987 ->GetDisplayNearestPoint(window->bounds().origin())
2988 .work_area();
2989 gfx::Rect tabbed_expected_bounds = work_area;
2990 tabbed_expected_bounds.ClampToCenteredSize(original_bounds.size());
2991 tabbed_expected_bounds.set_y(original_bounds.y());
2992 if (test_app)
2993 EXPECT_EQ(original_bounds.ToString(), window->bounds().ToString());
2994 else
2995 EXPECT_EQ(tabbed_expected_bounds.ToString(), window->bounds().ToString());
2996
2997 // Close the browser and re-create the browser window with the same app name.
2998 browser->window()->Close();
2999 browser = new Browser(params);
3000 browser->window()->Show();
3001
3002 // The newly created browser window should remain the same bounds for each.
3003 window = browser->window()->GetNativeWindow();
3004 if (test_app)
3005 EXPECT_EQ(original_bounds.ToString(), window->bounds().ToString());
3006 else
3007 EXPECT_EQ(tabbed_expected_bounds.ToString(), window->bounds().ToString());
3008 }
3009
3010 INSTANTIATE_TEST_CASE_P(BrowserTestTabbedOrApp,
3011 BrowserTestParam,
3012 testing::Bool());
3013
3014 #endif // defined(OS_CHROMEOS)
OLDNEW
« 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