Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 { EnableBrowserTest(); } | |
| 18 | |
| 19 void TearDownInProcessBrowserTestFixture() override { | |
| 20 const base::FilePath::StringType delete_suffix = | |
|
grt (UTC plus 2)
2016/05/27 16:26:28
nit: constexpr
grt (UTC plus 2)
2016/05/27 16:27:04
oops, nevermind. i read it as ::CharType rather th
| |
| 21 FILE_PATH_LITERAL(" (1).CHROME_DELETE"); | |
| 22 ASSERT_FALSE(base::DirectoryExists( | |
| 23 base::FilePath(user_data_dir_.value() + delete_suffix))); | |
| 24 } | |
| 25 | |
| 26 bool SetUpUserDataDirectory() override { | |
| 27 const base::FilePath::StringType last_chrome_version_file = | |
| 28 FILE_PATH_LITERAL("Last Chrome Version"); | |
| 29 if (!PathService::Get(chrome::DIR_USER_DATA, &user_data_dir_)) | |
| 30 return false; | |
| 31 if (!CreateTemporaryFileInDir(user_data_dir_, &other_file_)) | |
| 32 return false; | |
| 33 last_chrome_version_path_ = user_data_dir_.Append(last_chrome_version_file); | |
| 34 std::string last_chrome_version = | |
| 35 base::Version(std::string(chrome::kChromeVersion) + "1").GetString(); | |
| 36 base::WriteFile(last_chrome_version_path_, last_chrome_version.c_str(), | |
| 37 last_chrome_version.size()); | |
| 38 return true; | |
| 39 } | |
| 40 | |
| 41 base::FilePath last_chrome_version_path_; | |
| 42 base::FilePath other_file_; | |
| 43 base::FilePath user_data_dir_; | |
| 44 }; | |
| 45 | |
| 46 IN_PROC_BROWSER_TEST_F(UserDataDowngradeBrowserTest, CopyAndClean) { | |
| 47 std::string last_chrome_version_str; | |
| 48 base::ReadFileToString(last_chrome_version_path_, &last_chrome_version_str); | |
|
grt (UTC plus 2)
2016/05/27 16:26:28
please add comments to explain what this is testin
zmin
2016/05/27 17:43:00
Done.
| |
| 49 EXPECT_EQ(chrome::kChromeVersion, last_chrome_version_str); | |
| 50 ASSERT_FALSE(base::PathExists(other_file_)); | |
| 51 } | |
| OLD | NEW |