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

Unified 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: browser_tests Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
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_));
+}

Powered by Google App Engine
This is Rietveld 408576698