| 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/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/ui_test_utils.h" | 23 #include "chrome/test/base/ui_test_utils.h" |
| 23 #include "ui/gfx/rect.h" | 24 #include "ui/gfx/rect.h" |
| 24 | 25 |
| 25 class PreferenceServiceTest : public InProcessBrowserTest { | 26 class PreferenceServiceTest : public InProcessBrowserTest { |
| 26 public: | 27 public: |
| 27 explicit PreferenceServiceTest(bool new_profile) : new_profile_(new_profile) { | 28 explicit PreferenceServiceTest(bool new_profile) : new_profile_(new_profile) { |
| 28 } | 29 } |
| 29 | 30 |
| 30 virtual bool SetUpUserDataDirectory() OVERRIDE { | 31 virtual bool SetUpUserDataDirectory() OVERRIDE { |
| 31 FilePath user_data_directory; | 32 FilePath user_data_directory; |
| 32 PathService::Get(chrome::DIR_USER_DATA, &user_data_directory); | 33 PathService::Get(chrome::DIR_USER_DATA, &user_data_directory); |
| 33 | 34 |
| 34 FilePath reference_pref_file; | 35 FilePath reference_pref_file; |
| 35 if (new_profile_) { | 36 if (new_profile_) { |
| 36 reference_pref_file = ui_test_utils::GetTestFilePath( | 37 reference_pref_file = ui_test_utils::GetTestFilePath( |
| 37 FilePath().AppendASCII("profiles"). | 38 FilePath().AppendASCII("profiles"). |
| 38 AppendASCII("window_placement"). | 39 AppendASCII("window_placement"). |
| 39 AppendASCII("Default"), | 40 AppendASCII("Default"), |
| 40 FilePath().Append(chrome::kPreferencesFilename)); | 41 FilePath().Append(chrome::kPreferencesFilename)); |
| 41 tmp_pref_file_ = user_data_directory.AppendASCII("Default"); | 42 tmp_pref_file_ = |
| 43 user_data_directory.AppendASCII(TestingProfile::kTestUserProfileDir); |
| 42 CHECK(file_util::CreateDirectory(tmp_pref_file_)); | 44 CHECK(file_util::CreateDirectory(tmp_pref_file_)); |
| 43 tmp_pref_file_ = tmp_pref_file_.Append(chrome::kPreferencesFilename); | 45 tmp_pref_file_ = tmp_pref_file_.Append(chrome::kPreferencesFilename); |
| 44 } else { | 46 } else { |
| 45 reference_pref_file = ui_test_utils::GetTestFilePath( | 47 reference_pref_file = ui_test_utils::GetTestFilePath( |
| 46 FilePath().AppendASCII("profiles"). | 48 FilePath().AppendASCII("profiles"). |
| 47 AppendASCII("window_placement"), | 49 AppendASCII("window_placement"), |
| 48 FilePath().Append(chrome::kLocalStateFilename)); | 50 FilePath().Append(chrome::kLocalStateFilename)); |
| 49 tmp_pref_file_ = user_data_directory.Append(chrome::kLocalStateFilename); | 51 tmp_pref_file_ = user_data_directory.Append(chrome::kLocalStateFilename); |
| 50 } | 52 } |
| 51 | 53 |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 | 182 |
| 181 // Find if launched window is maximized. | 183 // Find if launched window is maximized. |
| 182 bool is_window_maximized = | 184 bool is_window_maximized = |
| 183 chrome::GetSavedWindowShowState(browser()) == ui::SHOW_STATE_MAXIMIZED; | 185 chrome::GetSavedWindowShowState(browser()) == ui::SHOW_STATE_MAXIMIZED; |
| 184 bool is_maximized = false; | 186 bool is_maximized = false; |
| 185 EXPECT_TRUE(root_dict->GetBoolean(kBrowserWindowPlacement + ".maximized", | 187 EXPECT_TRUE(root_dict->GetBoolean(kBrowserWindowPlacement + ".maximized", |
| 186 &is_maximized)); | 188 &is_maximized)); |
| 187 EXPECT_EQ(is_maximized, is_window_maximized); | 189 EXPECT_EQ(is_maximized, is_window_maximized); |
| 188 } | 190 } |
| 189 #endif | 191 #endif |
| OLD | NEW |