| OLD | NEW |
| 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/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
| 10 #include "base/json/json_file_value_serializer.h" | 10 #include "base/json/json_file_value_serializer.h" |
| 11 #include "base/path_service.h" | 11 #include "base/path_service.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/test_switches.h" | 22 #include "chrome/test/base/test_switches.h" |
| 23 #include "chrome/test/base/testing_profile.h" | 23 #include "chrome/test/base/testing_profile.h" |
| 24 #include "chrome/test/base/ui_test_utils.h" | 24 #include "chrome/test/base/ui_test_utils.h" |
| 25 #include "ui/gfx/rect.h" | 25 #include "ui/gfx/rect.h" |
| 26 | 26 |
| 27 // On GTK, resizing happens asynchronously and we currently don't have a way to | |
| 28 // get called back (it's probably possible, but we don't have that code). Since | |
| 29 // the GTK code is going away, not spending more time on this. | |
| 30 #if !defined(TOOLKIT_GTK) | |
| 31 | |
| 32 typedef InProcessBrowserTest PreservedWindowPlacement; | 27 typedef InProcessBrowserTest PreservedWindowPlacement; |
| 33 | 28 |
| 34 IN_PROC_BROWSER_TEST_F(PreservedWindowPlacement, PRE_Test) { | 29 IN_PROC_BROWSER_TEST_F(PreservedWindowPlacement, PRE_Test) { |
| 35 browser()->window()->SetBounds(gfx::Rect(20, 30, 400, 500)); | 30 browser()->window()->SetBounds(gfx::Rect(20, 30, 400, 500)); |
| 36 } | 31 } |
| 37 | 32 |
| 38 // Fails on Chrome OS as the browser thinks it is restarting after a crash, see | 33 // Fails on Chrome OS as the browser thinks it is restarting after a crash, see |
| 39 // http://crbug.com/168044 | 34 // http://crbug.com/168044 |
| 40 #if defined(OS_CHROMEOS) | 35 #if defined(OS_CHROMEOS) |
| 41 #define MAYBE_Test DISABLED_Test | 36 #define MAYBE_Test DISABLED_Test |
| 42 #else | 37 #else |
| 43 #define MAYBE_Test Test | 38 #define MAYBE_Test Test |
| 44 #endif | 39 #endif |
| 45 IN_PROC_BROWSER_TEST_F(PreservedWindowPlacement, MAYBE_Test) { | 40 IN_PROC_BROWSER_TEST_F(PreservedWindowPlacement, MAYBE_Test) { |
| 46 #if defined(OS_WIN) && defined(USE_ASH) | 41 #if defined(OS_WIN) && defined(USE_ASH) |
| 47 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | 42 // Disable this test in Metro+Ash for now (http://crbug.com/262796). |
| 48 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) | 43 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) |
| 49 return; | 44 return; |
| 50 #endif | 45 #endif |
| 51 | 46 |
| 52 gfx::Rect bounds = browser()->window()->GetBounds(); | 47 gfx::Rect bounds = browser()->window()->GetBounds(); |
| 53 gfx::Rect expected_bounds(gfx::Rect(20, 30, 400, 500)); | 48 gfx::Rect expected_bounds(gfx::Rect(20, 30, 400, 500)); |
| 54 ASSERT_EQ(expected_bounds.ToString(), bounds.ToString()); | 49 ASSERT_EQ(expected_bounds.ToString(), bounds.ToString()); |
| 55 } | 50 } |
| 56 | 51 |
| 57 #endif // defined(TOOLKIT_GTK) | |
| 58 | |
| 59 class PreferenceServiceTest : public InProcessBrowserTest { | 52 class PreferenceServiceTest : public InProcessBrowserTest { |
| 60 public: | 53 public: |
| 61 explicit PreferenceServiceTest(bool new_profile) : new_profile_(new_profile) { | 54 explicit PreferenceServiceTest(bool new_profile) : new_profile_(new_profile) { |
| 62 } | 55 } |
| 63 | 56 |
| 64 virtual bool SetUpUserDataDirectory() OVERRIDE { | 57 virtual bool SetUpUserDataDirectory() OVERRIDE { |
| 65 base::FilePath user_data_directory; | 58 base::FilePath user_data_directory; |
| 66 PathService::Get(chrome::DIR_USER_DATA, &user_data_directory); | 59 PathService::Get(chrome::DIR_USER_DATA, &user_data_directory); |
| 67 | 60 |
| 68 if (new_profile_) { | 61 if (new_profile_) { |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 EXPECT_EQ(right, bounds.x() + bounds.width()); | 220 EXPECT_EQ(right, bounds.x() + bounds.width()); |
| 228 | 221 |
| 229 // Find if launched window is maximized. | 222 // Find if launched window is maximized. |
| 230 bool is_window_maximized = browser()->window()->IsMaximized(); | 223 bool is_window_maximized = browser()->window()->IsMaximized(); |
| 231 bool is_maximized = false; | 224 bool is_maximized = false; |
| 232 EXPECT_TRUE(root_dict->GetBoolean(kBrowserWindowPlacement + ".maximized", | 225 EXPECT_TRUE(root_dict->GetBoolean(kBrowserWindowPlacement + ".maximized", |
| 233 &is_maximized)); | 226 &is_maximized)); |
| 234 EXPECT_EQ(is_maximized, is_window_maximized); | 227 EXPECT_EQ(is_maximized, is_window_maximized); |
| 235 } | 228 } |
| 236 #endif | 229 #endif |
| OLD | NEW |