Chromium Code Reviews| Index: chrome/browser/downgrade/user_data_downgrade_browsertest.cc |
| diff --git a/chrome/browser/downgrade/user_data_downgrade_browsertest.cc b/chrome/browser/downgrade/user_data_downgrade_browsertest.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..a9b746618f94949eb9b12ca3e22013760d5c8d34 |
| --- /dev/null |
| +++ b/chrome/browser/downgrade/user_data_downgrade_browsertest.cc |
| @@ -0,0 +1,51 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/downgrade/user_data_downgrade.h" |
| + |
| +#include "base/files/file_util.h" |
| +#include "base/path_service.h" |
| +#include "base/version.h" |
| +#include "chrome/common/chrome_constants.h" |
| +#include "chrome/common/chrome_paths.h" |
| +#include "chrome/test/base/in_process_browser_test.h" |
| +#include "content/public/browser/browser_thread.h" |
| + |
| +class UserDataDowngradeBrowserTest : public InProcessBrowserTest { |
| + protected: |
| + void SetUpInProcessBrowserTestFixture() override { EnableBrowserTest(); } |
| + |
| + void TearDownInProcessBrowserTestFixture() override { |
| + 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
|
| + FILE_PATH_LITERAL(" (1).CHROME_DELETE"); |
| + ASSERT_FALSE(base::DirectoryExists( |
| + base::FilePath(user_data_dir_.value() + delete_suffix))); |
| + } |
| + |
| + bool SetUpUserDataDirectory() override { |
| + const base::FilePath::StringType last_chrome_version_file = |
| + FILE_PATH_LITERAL("Last Chrome Version"); |
| + if (!PathService::Get(chrome::DIR_USER_DATA, &user_data_dir_)) |
| + return false; |
| + if (!CreateTemporaryFileInDir(user_data_dir_, &other_file_)) |
| + return false; |
| + last_chrome_version_path_ = user_data_dir_.Append(last_chrome_version_file); |
| + std::string last_chrome_version = |
| + base::Version(std::string(chrome::kChromeVersion) + "1").GetString(); |
| + base::WriteFile(last_chrome_version_path_, last_chrome_version.c_str(), |
| + last_chrome_version.size()); |
| + return true; |
| + } |
| + |
| + base::FilePath last_chrome_version_path_; |
| + base::FilePath other_file_; |
| + base::FilePath user_data_dir_; |
| +}; |
| + |
| +IN_PROC_BROWSER_TEST_F(UserDataDowngradeBrowserTest, CopyAndClean) { |
| + std::string last_chrome_version_str; |
| + 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.
|
| + EXPECT_EQ(chrome::kChromeVersion, last_chrome_version_str); |
| + ASSERT_FALSE(base::PathExists(other_file_)); |
| +} |