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

Unified Diff: chrome/browser/chrome_main_browsertest.cc

Issue 12662033: Show user data dialog earlier on Windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix windows build failures. Created 7 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chrome_main_browsertest.cc
diff --git a/chrome/browser/chrome_main_browsertest.cc b/chrome/browser/chrome_main_browsertest.cc
index c194e55f258489fa1dfb8516166ec7a44959462f..86081bc92860e22901e63921e746ba3775beab8d 100644
--- a/chrome/browser/chrome_main_browsertest.cc
+++ b/chrome/browser/chrome_main_browsertest.cc
@@ -23,6 +23,10 @@
#include "content/public/browser/web_contents.h"
#include "net/base/net_util.h"
+#if defined(OS_WIN)
+#include "chrome/browser/user_data_dir_extractor_win.h"
+#endif
+
// These tests don't apply to the Mac version; see GetCommandLineForRelaunch
// for details.
#if !defined(OS_MACOSX)
@@ -136,3 +140,49 @@ IN_PROC_BROWSER_TEST_F(ChromeMainTest, SecondLaunchFromIncognitoWithNormalUrl) {
}
#endif // !OS_MACOSX
+
+// These tests only apply to the Windows version; see chrome_browser_main.cc:
+// function GetUserDataDir() for details.
+#if defined(OS_WIN)
+class ChromeMainUserDataDirTest : public InProcessBrowserTest {
sky 2013/03/25 15:43:14 Move this to user_data_dir_extractor_win_browserte
hshi1 2013/03/25 17:18:55 Done.
+ public:
+ ChromeMainUserDataDirTest(): callback_invoked_(false) {}
sky 2013/03/25 15:43:14 nit: space between () and :
+
+ bool is_callback_invoked() { return callback_invoked_; }
sky 2013/03/25 15:43:14 field should either be named is_callback_invoked_
hshi1 2013/03/25 17:18:55 Done.
+ void ShowUserDataDirDialog() {
sky 2013/03/25 15:43:14 Move to private.
hshi1 2013/03/25 17:18:55 Done.
+ // Set callback invoked flag and restore the correct user data dir.
+ callback_invoked_ = true;
+ PathService::Override(chrome::DIR_USER_DATA, user_data_dir_);
+ }
+
+ protected:
+ base::FilePath user_data_dir_;
sky 2013/03/25 15:43:14 fields at end of section.
hshi1 2013/03/25 17:18:55 Done.
+ base::Closure callback_;
+ bool callback_invoked_;
+
+ virtual void SetUp() OVERRIDE {
+ InProcessBrowserTest::SetUp();
+
+ // Save the actual user data dir.
+ PathService::Get(chrome::DIR_USER_DATA, &user_data_dir_);
+
+ // Override user data dir to a bogus value. Make sure to set |create| flag
+ // to false so that PathService::OverrideAndCreateIfNeeded does not create
+ // a folder at this path.
+ base::FilePath bogus_user_data_dir("/bogus/should/not/exist");
+ PathService::OverrideAndCreateIfNeeded(chrome::DIR_USER_DATA,
+ bogus_user_data_dir,
+ false);
+
+ // Install custom ShowUserDataDirDialog callback.
+ callback_ = base::Bind(&ChromeMainUserDataDirTest::ShowUserDataDirDialog,
+ this);
+ chrome::InstallCustomShowUserDataDirDialogCallbackForTest(&callback_);
+ }
+};
sky 2013/03/25 15:43:14 private:: DISALLOW...
hshi1 2013/03/25 17:18:55 Done.
+
+IN_PROC_BROWSER_TEST_F(ChromeMainUserDataDirTest, BogusUserDataDir) {
+ // The ShowUserDataDirDialog should have been invoked and we did not crash.
+ ASSERT_TRUE(is_callback_invoked());
+}
+#endif // OS_WIN

Powered by Google App Engine
This is Rietveld 408576698