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

Side by Side Diff: chrome/browser/profiles/profile_browsertest.cc

Issue 213473005: Remove PlatformFile from profile_browsertest (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "chrome/browser/profiles/profile.h" 5 #include "chrome/browser/profiles/profile.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/files/scoped_temp_dir.h" 8 #include "base/files/scoped_temp_dir.h"
9 #include "base/platform_file.h"
10 #include "base/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
11 #include "base/version.h" 10 #include "base/version.h"
12 #include "chrome/browser/chrome_notification_types.h" 11 #include "chrome/browser/chrome_notification_types.h"
13 #include "chrome/browser/profiles/chrome_version_service.h" 12 #include "chrome/browser/profiles/chrome_version_service.h"
14 #include "chrome/browser/profiles/profile_impl.h" 13 #include "chrome/browser/profiles/profile_impl.h"
15 #include "chrome/browser/profiles/startup_task_runner_service.h" 14 #include "chrome/browser/profiles/startup_task_runner_service.h"
16 #include "chrome/browser/profiles/startup_task_runner_service_factory.h" 15 #include "chrome/browser/profiles/startup_task_runner_service_factory.h"
17 #include "chrome/common/chrome_constants.h" 16 #include "chrome/common/chrome_constants.h"
18 #include "chrome/common/chrome_version_info.h" 17 #include "chrome/common/chrome_version_info.h"
19 #include "chrome/common/pref_names.h" 18 #include "chrome/common/pref_names.h"
20 #include "chrome/test/base/in_process_browser_test.h" 19 #include "chrome/test/base/in_process_browser_test.h"
21 #include "chrome/test/base/ui_test_utils.h" 20 #include "chrome/test/base/ui_test_utils.h"
22 #include "testing/gmock/include/gmock/gmock.h" 21 #include "testing/gmock/include/gmock/gmock.h"
23 #include "testing/gtest/include/gtest/gtest.h" 22 #include "testing/gtest/include/gtest/gtest.h"
24 23
25 namespace { 24 namespace {
26 25
27 class MockProfileDelegate : public Profile::Delegate { 26 class MockProfileDelegate : public Profile::Delegate {
28 public: 27 public:
29 MOCK_METHOD1(OnPrefsLoaded, void(Profile*)); 28 MOCK_METHOD1(OnPrefsLoaded, void(Profile*));
30 MOCK_METHOD3(OnProfileCreated, void(Profile*, bool, bool)); 29 MOCK_METHOD3(OnProfileCreated, void(Profile*, bool, bool));
31 }; 30 };
32 31
33 // Creates a prefs file in the given directory. 32 // Creates a prefs file in the given directory.
34 void CreatePrefsFileInDirectory(const base::FilePath& directory_path) { 33 void CreatePrefsFileInDirectory(const base::FilePath& directory_path) {
35 base::FilePath pref_path(directory_path.Append(chrome::kPreferencesFilename)); 34 base::FilePath pref_path(directory_path.Append(chrome::kPreferencesFilename));
36 base::PlatformFile file = base::CreatePlatformFile(pref_path,
37 base::PLATFORM_FILE_CREATE | base::PLATFORM_FILE_WRITE, NULL, NULL);
38 ASSERT_TRUE(file != base::kInvalidPlatformFileValue);
39 ASSERT_TRUE(base::ClosePlatformFile(file));
40 std::string data("{}"); 35 std::string data("{}");
41 ASSERT_TRUE(base::WriteFile(pref_path, data.c_str(), data.size())); 36 ASSERT_TRUE(base::WriteFile(pref_path, data.c_str(), data.size()));
42 } 37 }
43 38
44 void CheckChromeVersion(Profile *profile, bool is_new) { 39 void CheckChromeVersion(Profile *profile, bool is_new) {
45 std::string created_by_version; 40 std::string created_by_version;
46 if (is_new) { 41 if (is_new) {
47 chrome::VersionInfo version_info; 42 chrome::VersionInfo version_info;
48 created_by_version = version_info.Version(); 43 created_by_version = version_info.Version();
49 } else { 44 } else {
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 std::string final_value(prefs->GetString(prefs::kSessionExitType)); 239 std::string final_value(prefs->GetString(prefs::kSessionExitType));
245 EXPECT_EQ(crash_value, final_value); 240 EXPECT_EQ(crash_value, final_value);
246 241
247 // This test runs fast enough that the WebDataService may still be 242 // This test runs fast enough that the WebDataService may still be
248 // initializing (which uses the temp directory) when the test 243 // initializing (which uses the temp directory) when the test
249 // ends. Give it a chance to complete. 244 // ends. Give it a chance to complete.
250 profile.reset(); 245 profile.reset();
251 content::RunAllPendingInMessageLoop(); 246 content::RunAllPendingInMessageLoop();
252 content::RunAllPendingInMessageLoop(content::BrowserThread::DB); 247 content::RunAllPendingInMessageLoop(content::BrowserThread::DB);
253 } 248 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698