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

Side by Side Diff: chrome/browser/downgrade/user_data_downgrade_browsertest.cc

Issue 1986823002: Reset user data directory and disk cache directory after downgrade. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cr Created 4 years, 6 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
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/downgrade/user_data_downgrade.h"
6
7 #include "base/files/file_util.h"
8 #include "base/path_service.h"
9 #include "base/version.h"
10 #include "chrome/common/chrome_constants.h"
11 #include "chrome/common/chrome_paths.h"
12 #include "chrome/test/base/in_process_browser_test.h"
13 #include "content/public/browser/browser_thread.h"
14
15 class UserDataDowngradeBrowserTest : public InProcessBrowserTest {
16 protected:
17 void SetUpInProcessBrowserTestFixture() override {
18 SimulateDowngradeForTest();
grt (UTC plus 2) 2016/05/31 19:44:48 suggestion: since this sets a process-wide singlet
zmin 2016/05/31 20:08:33 Done.
19 }
20
21 // Verify the renamed user data directory has been deleted.
22 void TearDownInProcessBrowserTestFixture() override {
23 const base::FilePath::StringType delete_suffix =
24 FILE_PATH_LITERAL(" (1).CHROME_DELETE");
25 ASSERT_FALSE(base::DirectoryExists(
26 base::FilePath(user_data_dir_.value() + delete_suffix)));
27 }
28
29 bool SetUpUserDataDirectory() override {
30 const base::FilePath::StringType last_chrome_version_file =
31 FILE_PATH_LITERAL("Last Chrome Version");
32 if (!PathService::Get(chrome::DIR_USER_DATA, &user_data_dir_))
33 return false;
34 if (!CreateTemporaryFileInDir(user_data_dir_, &other_file_))
35 return false;
36 last_chrome_version_path_ = user_data_dir_.Append(last_chrome_version_file);
37 std::string last_chrome_version =
38 base::Version(std::string(chrome::kChromeVersion) + "1").GetString();
39 base::WriteFile(last_chrome_version_path_, last_chrome_version.c_str(),
40 last_chrome_version.size());
41 return true;
42 }
43
44 base::FilePath last_chrome_version_path_;
45 base::FilePath other_file_;
46 base::FilePath user_data_dir_;
47 };
48
49 // Verify the user data directory has been renamed and created again after
50 // downgrade.
51 IN_PROC_BROWSER_TEST_F(UserDataDowngradeBrowserTest, CopyAndClean) {
52 std::string last_chrome_version_str;
53 base::ReadFileToString(last_chrome_version_path_, &last_chrome_version_str);
54 EXPECT_EQ(chrome::kChromeVersion, last_chrome_version_str);
55 ASSERT_FALSE(base::PathExists(other_file_));
56 }
OLDNEW
« no previous file with comments | « chrome/browser/downgrade/user_data_downgrade.cc ('k') | chrome/browser/policy/policy_path_parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698