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

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: Add a browser test as suggested by Scott. 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..6aba1615510c14f39a17e2468d4b723556f30a56 100644
--- a/chrome/browser/chrome_main_browsertest.cc
+++ b/chrome/browser/chrome_main_browsertest.cc
@@ -12,6 +12,7 @@
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
+#include "chrome/browser/ui/user_data_dir_dialog.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
@@ -136,3 +137,47 @@ 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 {
+ public:
+ ChromeMainUserDataDirTest(): callback_invoked_(false) {}
+
+ bool is_callback_invoked() { return callback_invoked_; }
+ void ShowUserDataDirDialog() {
+ // 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_;
+ 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.
+ chrome::InstallCustomShowUserDataDirDialogCallbackForTest(
+ base::Bind(&ChromeMainUserDataDirTest::ShowUserDataDirDialog, this));
+ }
+};
+
+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