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

Side by Side Diff: chrome/browser/prefs/pref_service_browsertest.cc

Issue 11085053: Improving window auto management between workspaces (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: git try Created 8 years, 2 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
OLDNEW
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 <string> 5 #include <string>
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/json/json_file_value_serializer.h" 9 #include "base/json/json_file_value_serializer.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
11 #include "base/scoped_temp_dir.h" 11 #include "base/scoped_temp_dir.h"
12 #include "base/test/test_file_util.h" 12 #include "base/test/test_file_util.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "build/build_config.h" 14 #include "build/build_config.h"
15 #include "chrome/browser/ui/browser.h" 15 #include "chrome/browser/ui/browser.h"
16 #include "chrome/browser/ui/browser_window.h" 16 #include "chrome/browser/ui/browser_window.h"
17 #include "chrome/browser/ui/browser_window_state.h" 17 #include "chrome/browser/ui/browser_window_state.h"
18 #include "chrome/common/chrome_constants.h" 18 #include "chrome/common/chrome_constants.h"
19 #include "chrome/common/chrome_paths.h" 19 #include "chrome/common/chrome_paths.h"
20 #include "chrome/common/pref_names.h" 20 #include "chrome/common/pref_names.h"
21 #include "chrome/test/base/in_process_browser_test.h" 21 #include "chrome/test/base/in_process_browser_test.h"
22 #include "chrome/test/base/testing_profile.h" 22 #include "chrome/test/base/testing_profile.h"
23 #include "chrome/test/base/ui_test_utils.h" 23 #include "chrome/test/base/ui_test_utils.h"
24 #include "ui/gfx/rect.h" 24 #include "ui/gfx/rect.h"
25 25
26 #if defined(USE_ASH)
27 #include "ash/wm/window_util.h"
28 #endif
29
26 // On GTK, resizing happens asynchronously and we currently don't have a way to 30 // On GTK, resizing happens asynchronously and we currently don't have a way to
27 // get called back (it's probably possible, but we don't have that code). Since 31 // get called back (it's probably possible, but we don't have that code). Since
28 // the GTK code is going away, not spending more time on this. 32 // the GTK code is going away, not spending more time on this.
29 #if !defined(TOOLKIT_GTK) 33 #if !defined(TOOLKIT_GTK)
30 34
31 typedef InProcessBrowserTest PreservedWindowPlacement; 35 typedef InProcessBrowserTest PreservedWindowPlacement;
32 36
33 IN_PROC_BROWSER_TEST_F(PreservedWindowPlacement, PRE_Test) { 37 IN_PROC_BROWSER_TEST_F(PreservedWindowPlacement, PRE_Test) {
38 #if defined(USE_ASH)
39 // The window needs to be tagged as user positioned, otherwise it would get
40 // re-positioned.
41 ash::wm::SetUserHasChangedWindowPositionOrSize(
42 browser()->window()->GetNativeWindow(),
43 true);
44 #endif
34 browser()->window()->SetBounds(gfx::Rect(20, 30, 400, 500)); 45 browser()->window()->SetBounds(gfx::Rect(20, 30, 400, 500));
35 } 46 }
36 47
37 IN_PROC_BROWSER_TEST_F(PreservedWindowPlacement, Test) { 48 IN_PROC_BROWSER_TEST_F(PreservedWindowPlacement, Test) {
38 gfx::Rect bounds = browser()->window()->GetBounds(); 49 gfx::Rect bounds = browser()->window()->GetBounds();
39 50 #if defined(USE_ASH)
51 EXPECT_TRUE(ash::wm::HasUserChangedWindowPositionOrSize(
52 browser()->window()->GetNativeWindow()));
53 #endif
40 gfx::Rect expected_bounds(gfx::Rect(20, 30, 400, 500)); 54 gfx::Rect expected_bounds(gfx::Rect(20, 30, 400, 500));
41 ASSERT_EQ(expected_bounds, bounds); 55 ASSERT_EQ(expected_bounds.ToString(), bounds.ToString());
42 } 56 }
43 57
44 #endif // defined(TOOLKIT_GTK) 58 #endif // defined(TOOLKIT_GTK)
45 59
46 class PreferenceServiceTest : public InProcessBrowserTest { 60 class PreferenceServiceTest : public InProcessBrowserTest {
47 public: 61 public:
48 explicit PreferenceServiceTest(bool new_profile) : new_profile_(new_profile) { 62 explicit PreferenceServiceTest(bool new_profile) : new_profile_(new_profile) {
49 } 63 }
50 64
51 virtual bool SetUpUserDataDirectory() OVERRIDE { 65 virtual bool SetUpUserDataDirectory() OVERRIDE {
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 EXPECT_EQ(right, bounds.x() + bounds.width()); 214 EXPECT_EQ(right, bounds.x() + bounds.width());
201 215
202 // Find if launched window is maximized. 216 // Find if launched window is maximized.
203 bool is_window_maximized = browser()->window()->IsMaximized(); 217 bool is_window_maximized = browser()->window()->IsMaximized();
204 bool is_maximized = false; 218 bool is_maximized = false;
205 EXPECT_TRUE(root_dict->GetBoolean(kBrowserWindowPlacement + ".maximized", 219 EXPECT_TRUE(root_dict->GetBoolean(kBrowserWindowPlacement + ".maximized",
206 &is_maximized)); 220 &is_maximized));
207 EXPECT_EQ(is_maximized, is_window_maximized); 221 EXPECT_EQ(is_maximized, is_window_maximized);
208 } 222 }
209 #endif 223 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698