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

Unified Diff: chrome/browser/profiles/profile_manager_browsertest.cc

Issue 2061593002: Fix crash when switching to a profile that cannot be opened (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bug-614753-fix
Patch Set: Created 4 years, 6 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/profiles/profile_manager_browsertest.cc
diff --git a/chrome/browser/profiles/profile_manager_browsertest.cc b/chrome/browser/profiles/profile_manager_browsertest.cc
index 06f06dc2d8fa4b9e2843c2751ce1d1f706ab6001..d49b774848d0c6bd443b8c5859c378b271919c21 100644
--- a/chrome/browser/profiles/profile_manager_browsertest.cc
+++ b/chrome/browser/profiles/profile_manager_browsertest.cc
@@ -4,6 +4,7 @@
#include <stddef.h>
+#include "base/base_switches.h"
#include "base/bind.h"
#include "base/command_line.h"
#include "base/macros.h"
@@ -36,6 +37,11 @@
#include "testing/gtest/include/gtest/gtest.h"
#endif
+#if defined(OS_WIN)
+#include <windows.h>
+#include "base/test/test_file_util.h"
+#endif
+
namespace {
const ProfileManager::CreateCallback kOnProfileSwitchDoNothing;
@@ -148,6 +154,7 @@ class ProfileManagerBrowserTest : public InProcessBrowserTest {
command_line->AppendSwitch(
chromeos::switches::kIgnoreUserProfileMappingForTests);
#endif
+ command_line->AppendSwitch(switches::kNoErrorDialogs);
}
};
@@ -297,8 +304,7 @@ IN_PROC_BROWSER_TEST_F(ProfileManagerBrowserTest,
}
}
-IN_PROC_BROWSER_TEST_F(ProfileManagerBrowserTest,
- SwitchToProfile) {
+IN_PROC_BROWSER_TEST_F(ProfileManagerBrowserTest, SwitchToProfile) {
// If multiprofile mode is not enabled, you can't switch between profiles.
if (!profiles::IsMultipleProfilesEnabled())
return;
@@ -352,6 +358,20 @@ IN_PROC_BROWSER_TEST_F(ProfileManagerBrowserTest,
EXPECT_EQ(path_profile2, browser_list->get(1)->profile()->GetPath());
}
+#if defined(OS_WIN)
Peter Kasting 2016/06/13 04:43:20 It would be nice to be able to run this test on al
WC Leung 2016/06/13 08:06:45 Sadly I don't think that is possible. I've done a
WC Leung 2016/06/15 13:08:39 I mean confirm with the crash logs (I don't have a
+IN_PROC_BROWSER_TEST_F(ProfileManagerBrowserTest, SwitchToProfileFails) {
+ base::FilePath user_data_dir =
+ g_browser_process->profile_manager()->user_data_dir();
+ base::DenyFilePermission(user_data_dir, FILE_ADD_SUBDIRECTORY);
+ // Switch to a profile that cannot be loaded or created. This must fail
+ // gracefully with no crash.
+ profiles::SwitchToProfile(user_data_dir.AppendASCII("Profile 1"),
+ false,
+ kOnProfileSwitchDoNothing,
+ ProfileMetrics::SWITCH_PROFILE_ICON);
+}
+#endif // defined(OS_WIN)
+
// Flakes on Windows: http://crbug.com/314905
#if defined(OS_WIN)
#define MAYBE_EphemeralProfile DISABLED_EphemeralProfile

Powered by Google App Engine
This is Rietveld 408576698