Index: chrome/browser/chrome_main_browsertest.cc |
diff --git a/chrome/browser/chrome_main_browsertest.cc b/chrome/browser/chrome_main_browsertest.cc |
index 30bcf7156c9e7fddd1c0cc3db0e5d301ce2ae4b0..88d254894ab91100dda9c783c788b7c684ba7f99 100644 |
--- a/chrome/browser/chrome_main_browsertest.cc |
+++ b/chrome/browser/chrome_main_browsertest.cc |
@@ -7,6 +7,7 @@ |
#include "base/command_line.h" |
#include "base/path_service.h" |
#include "base/process/launch.h" |
+#include "base/strings/utf_string_conversions.h" |
#include "chrome/browser/chrome_notification_types.h" |
#include "chrome/browser/ui/browser.h" |
#include "chrome/browser/ui/browser_commands.h" |
@@ -14,15 +15,22 @@ |
#include "chrome/browser/ui/tabs/tab_strip_model.h" |
#include "chrome/common/chrome_paths.h" |
#include "chrome/common/chrome_switches.h" |
+#include "chrome/common/chrome_version_info.h" |
#include "chrome/test/base/in_process_browser_test.h" |
#include "chrome/test/base/test_switches.h" |
#include "chrome/test/base/ui_test_utils.h" |
+#include "chrome_elf/blacklist/blacklist.h" |
#include "content/public/browser/navigation_controller.h" |
#include "content/public/browser/navigation_entry.h" |
#include "content/public/browser/notification_service.h" |
#include "content/public/browser/web_contents.h" |
+#include "content/public/common/content_switches.h" |
#include "net/base/net_util.h" |
+#if defined(OS_WIN) |
+#include "base/test/test_reg_util_win.h" |
+#endif |
+ |
// These tests don't apply to the Mac version; see GetCommandLineForRelaunch |
// for details. |
#if !defined(OS_MACOSX) |
@@ -153,4 +161,136 @@ IN_PROC_BROWSER_TEST_F(ChromeMainTest, SecondLaunchFromIncognitoWithNormalUrl) { |
ASSERT_EQ(1u, chrome::GetTabbedBrowserCount(profile, host_desktop_type)); |
} |
+#if defined(OS_WIN) |
+ |
+class ChromeBlacklistTrialTest : public InProcessBrowserTest { |
+ protected: |
+ ChromeBlacklistTrialTest() {} |
+ |
+ virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
+ command_line->AppendSwitchASCII(switches::kForceFieldTrials, |
+ "BrowserBlacklist/Enabled/"); |
+ } |
+ |
+ virtual void SetUpInProcessBrowserTestFixture() { |
+ registry_util::RegistryOverrideManager override_manager; |
+ override_manager.OverrideRegistry(HKEY_CURRENT_USER, |
+ L"browser_blacklist_test"); |
+ } |
+ |
+ DWORD GetBlacklistState() { |
+ DWORD blacklist_state; |
robertshield
2013/12/27 03:24:29
= 0
csharp
2014/01/02 19:55:36
Done.
|
+ DWORD blacklist_state_size = sizeof(blacklist_state); |
+ |
+ ::RegGetValue(HKEY_CURRENT_USER, |
robertshield
2013/12/27 03:24:29
use base/win/registry here too
csharp
2014/01/02 19:55:36
Done.
|
+ blacklist::kRegistryBeaconPath, |
+ blacklist::kBeaconState, |
+ RRF_RT_REG_DWORD, |
+ NULL, |
+ &blacklist_state, |
+ &blacklist_state_size); |
+ return blacklist_state; |
+ } |
+ |
+ string16 GetBlacklistVersion() { |
+ wchar_t key_data[255]; |
robertshield
2013/12/27 03:24:29
= {}
csharp
2014/01/02 19:55:36
Done.
|
+ DWORD key_data_size = sizeof(key_data); |
+ |
+ ::RegGetValue(HKEY_CURRENT_USER, |
+ blacklist::kRegistryBeaconPath, |
+ blacklist::kBeaconVersion, |
+ RRF_RT_REG_SZ, |
+ NULL, |
+ key_data, |
+ &key_data_size); |
+ |
+ return key_data; |
+ } |
+ |
+ private: |
+ DISALLOW_COPY_AND_ASSIGN(ChromeBlacklistTrialTest); |
+}; |
+ |
+class ChromeBlacklistTrialFirstRun : public ChromeBlacklistTrialTest { |
robertshield
2013/12/27 03:24:29
This class appears to be empty, does it need to ex
csharp
2014/01/02 19:55:36
Done.
|
+ protected: |
+ ChromeBlacklistTrialFirstRun() {} |
+ |
+ private: |
+ DISALLOW_COPY_AND_ASSIGN(ChromeBlacklistTrialFirstRun); |
+}; |
+ |
+IN_PROC_BROWSER_TEST_F(ChromeBlacklistTrialFirstRun, Verify) { |
+ ASSERT_EQ(blacklist::BLACKLIST_ENABLED, GetBlacklistState()); |
+ |
+ chrome::VersionInfo version_info; |
+ string16 version = UTF8ToUTF16(version_info.Version()); |
+ ASSERT_EQ(version, GetBlacklistVersion()); |
+} |
+ |
+class ChromeBlacklistTrialSetupFailed : public ChromeBlacklistTrialTest { |
+ protected: |
+ ChromeBlacklistTrialSetupFailed() {} |
+ |
+ virtual void SetUpInProcessBrowserTestFixture() { |
+ ChromeBlacklistTrialTest::SetUpInProcessBrowserTestFixture(); |
+ |
+ // Set the registry to indicate that the blacklist setup is running, |
robertshield
2013/12/27 03:24:29
nit: double space before running
csharp
2014/01/02 19:55:36
Done.
|
+ // which means it failed to run correctly last time. |
+ DWORD blacklist_state = blacklist::BLACKLIST_SETUP_RUNNING; |
+ ::RegSetKeyValue(HKEY_CURRENT_USER, |
+ blacklist::kRegistryBeaconPath, |
+ blacklist::kBeaconState, |
+ REG_DWORD, |
+ &blacklist_state, |
+ sizeof(blacklist_state)); |
+ } |
+ |
+ private: |
+ DISALLOW_COPY_AND_ASSIGN(ChromeBlacklistTrialSetupFailed); |
+}; |
+ |
+IN_PROC_BROWSER_TEST_F(ChromeBlacklistTrialSetupFailed, Verify) { |
+ // Since the blacklist setup failed, it should now be disabled. |
+ ASSERT_EQ(blacklist::BLACKLIST_DISABLED, GetBlacklistState()); |
+} |
+ |
+class ChromeBlacklistTrialVersionChanged : public ChromeBlacklistTrialTest { |
+ protected: |
+ ChromeBlacklistTrialVersionChanged() {} |
+ |
+ virtual void SetUpInProcessBrowserTestFixture() { |
+ ChromeBlacklistTrialTest::SetUpInProcessBrowserTestFixture(); |
+ |
+ // Mark the blacklist as disabled for an older version, so it should |
+ // be enabled again for the new version. |
+ string16 version = L"old_version"; |
+ ::RegSetKeyValue(HKEY_CURRENT_USER, |
+ blacklist::kRegistryBeaconPath, |
+ blacklist::kBeaconVersion, |
+ REG_SZ, |
+ version.c_str(), |
+ version.size() * sizeof(wchar_t)); |
+ |
+ DWORD blacklist_state = blacklist::BLACKLIST_DISABLED; |
+ ::RegSetKeyValue(HKEY_CURRENT_USER, |
+ blacklist::kRegistryBeaconPath, |
+ blacklist::kBeaconState, |
+ REG_DWORD, |
+ &blacklist_state, |
+ sizeof(blacklist_state)); |
+ } |
+ |
+ private: |
+ DISALLOW_COPY_AND_ASSIGN(ChromeBlacklistTrialVersionChanged); |
+}; |
+ |
+IN_PROC_BROWSER_TEST_F(ChromeBlacklistTrialVersionChanged, Verify) { |
+ ASSERT_EQ(blacklist::BLACKLIST_ENABLED, GetBlacklistState()); |
+ |
+ chrome::VersionInfo version_info; |
+ string16 version = UTF8ToUTF16(version_info.Version()); |
+ ASSERT_EQ(version, GetBlacklistVersion()); |
+} |
+#endif |
+ |
#endif // !OS_MACOSX |