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

Unified Diff: chrome_elf/chrome_elf_util_unittest.cc

Issue 1963373003: Revert of Remove dependencies on chrome\installer from the ChromeCrashReporterClient class on Windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
« no previous file with comments | « chrome_elf/chrome_elf_main.cc ('k') | chrome_elf/elf_imports_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome_elf/chrome_elf_util_unittest.cc
diff --git a/chrome_elf/chrome_elf_util_unittest.cc b/chrome_elf/chrome_elf_util_unittest.cc
index a41a5bcfc7a84bc89e1245aabc4d01cc51929461..26b3a26cdd1a62764ae11404df7edf71f17ce02e 100644
--- a/chrome_elf/chrome_elf_util_unittest.cc
+++ b/chrome_elf/chrome_elf_util_unittest.cc
@@ -10,9 +10,20 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/platform_test.h"
-using namespace install_static;
+namespace {
-namespace {
+const wchar_t kRegPathClientState[] = L"Software\\Google\\Update\\ClientState";
+const wchar_t kRegPathClientStateMedium[] =
+ L"Software\\Google\\Update\\ClientStateMedium";
+const wchar_t kRegValueUsageStats[] = L"usagestats";
+const wchar_t kUninstallArgumentsField[] = L"UninstallArguments";
+
+const wchar_t kAppGuidCanary[] =
+ L"{4ea16ac7-fd5a-47c3-875b-dbf4a2008c20}";
+const wchar_t kAppGuidGoogleChrome[] =
+ L"{8A69D345-D564-463c-AFF1-A69D9E530F96}";
+const wchar_t kAppGuidGoogleBinaries[] =
+ L"{4DC8B4CA-1BDA-483e-B5FA-D3C12E15B62D}";
const wchar_t kCanaryExePath[] =
L"C:\\Users\\user\\AppData\\Local\\Google\\Chrome SxS\\Application"
@@ -24,10 +35,11 @@
const wchar_t kChromiumExePath[] =
L"C:\\Users\\user\\AppData\\Local\\Chromium\\Application\\chrome.exe";
+
TEST(ChromeElfUtilTest, CanaryTest) {
- EXPECT_TRUE(IsSxSChrome(kCanaryExePath));
- EXPECT_FALSE(IsSxSChrome(kChromeUserExePath));
- EXPECT_FALSE(IsSxSChrome(kChromiumExePath));
+ EXPECT_TRUE(IsCanary(kCanaryExePath));
+ EXPECT_FALSE(IsCanary(kChromeUserExePath));
+ EXPECT_FALSE(IsCanary(kChromiumExePath));
}
TEST(ChromeElfUtilTest, SystemInstallTest) {
@@ -107,221 +119,6 @@
ASSERT_EQ(ERROR_SUCCESS, result);
}
- void SetChannelName(const base::string16& channel_name) {
- LONG result = base::win::RegKey(
- system_level_ ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER,
- BuildKey(kRegPathClientState, app_guid_).c_str(),
- KEY_SET_VALUE).WriteValue(kRegApField, channel_name.c_str());
- ASSERT_EQ(ERROR_SUCCESS, result);
- }
-
- // This function tests the install_static::GetChromeChannelName function and
- // is based on the ChannelInfoTest.Channels in channel_info_unittest.cc.
- // The |add_modifier| parameter controls whether we expect modifiers in the
- // returned channel name.
- void PerformChannelNameTests(bool add_modifier) {
- // We can't test the channel name correctly for canary mode because the
- // install_static checks whether an exe is a canary executable is based on
- // the path where the exe is running from.
- if (is_canary_)
- return;
- SetChannelName(L"");
- base::string16 channel;
- install_static::GetChromeChannelName(!system_level_, add_modifier,
- &channel);
- if (multi_install_ && add_modifier) {
- EXPECT_EQ(L"-m", channel);
- } else {
- EXPECT_EQ(install_static::kChromeChannelStable, channel);
- }
-
- SetChannelName(L"-full");
- install_static::GetChromeChannelName(!system_level_, add_modifier,
- &channel);
- if (multi_install_ && add_modifier) {
- EXPECT_EQ(L"-m", channel);
- } else {
- EXPECT_EQ(install_static::kChromeChannelStable, channel);
- }
-
- SetChannelName(L"1.1-beta");
- install_static::GetChromeChannelName(!system_level_, add_modifier,
- &channel);
- if (multi_install_ && add_modifier) {
- EXPECT_EQ(L"beta-m", channel);
- } else {
- EXPECT_EQ(install_static::kChromeChannelBeta, channel);
- }
-
- SetChannelName(L"1.1-beta");
- install_static::GetChromeChannelName(!system_level_, add_modifier,
- &channel);
- if (multi_install_ && add_modifier) {
- EXPECT_EQ(L"beta-m", channel);
- } else {
- EXPECT_EQ(install_static::kChromeChannelBeta, channel);
- }
-
- SetChannelName(L"1.1-bar");
- install_static::GetChromeChannelName(!system_level_, add_modifier,
- &channel);
- if (multi_install_ && add_modifier) {
- EXPECT_EQ(L"beta-m", channel);
- } else {
- EXPECT_EQ(install_static::kChromeChannelBeta, channel);
- }
-
- SetChannelName(L"1n1-foobar");
- install_static::GetChromeChannelName(!system_level_, add_modifier,
- &channel);
- if (multi_install_ && add_modifier) {
- EXPECT_EQ(L"beta-m", channel);
- } else {
- EXPECT_EQ(install_static::kChromeChannelBeta, channel);
- }
-
- SetChannelName(L"foo-1.1-beta");
- install_static::GetChromeChannelName(!system_level_, add_modifier,
- &channel);
- if (multi_install_ && add_modifier) {
- EXPECT_EQ(L"-m", channel);
- } else {
- EXPECT_EQ(install_static::kChromeChannelStable, channel);
- }
- SetChannelName(L"2.0-beta");
- install_static::GetChromeChannelName(!system_level_, add_modifier,
- &channel);
- if (multi_install_ && add_modifier) {
- EXPECT_EQ(L"-m", channel);
- } else {
- EXPECT_EQ(install_static::kChromeChannelStable, channel);
- }
-
- SetChannelName(L"2.0-dev");
- install_static::GetChromeChannelName(!system_level_, add_modifier,
- &channel);
- if (multi_install_ && add_modifier) {
- EXPECT_EQ(L"dev-m", channel);
- } else {
- EXPECT_EQ(install_static::kChromeChannelDev, channel);
- }
- SetChannelName(L"2.0-DEV");
- install_static::GetChromeChannelName(!system_level_, add_modifier,
- &channel);
- if (multi_install_ && add_modifier) {
- EXPECT_EQ(L"dev-m", channel);
- } else {
- EXPECT_EQ(install_static::kChromeChannelDev, channel);
- }
- SetChannelName(L"2.0-dev-eloper");
- install_static::GetChromeChannelName(!system_level_, add_modifier,
- &channel);
- if (multi_install_ && add_modifier) {
- EXPECT_EQ(L"dev-m", channel);
- } else {
- EXPECT_EQ(install_static::kChromeChannelDev, channel);
- }
- SetChannelName(L"2.0-doom");
- install_static::GetChromeChannelName(!system_level_, add_modifier,
- &channel);
- if (multi_install_ && add_modifier) {
- EXPECT_EQ(L"dev-m", channel);
- } else {
- EXPECT_EQ(install_static::kChromeChannelDev, channel);
- }
- SetChannelName(L"250-doom");
- install_static::GetChromeChannelName(!system_level_, add_modifier,
- &channel);
- if (multi_install_ && add_modifier) {
- EXPECT_EQ(L"dev-m", channel);
- } else {
- EXPECT_EQ(install_static::kChromeChannelDev, channel);
- }
- SetChannelName(L"bar-2.0-dev");
- install_static::GetChromeChannelName(!system_level_, add_modifier,
- &channel);
- if (multi_install_ && add_modifier) {
- EXPECT_EQ(L"-m", channel);
- } else {
- EXPECT_EQ(install_static::kChromeChannelStable, channel);
- }
- SetChannelName(L"1.0-dev");
- install_static::GetChromeChannelName(!system_level_, add_modifier,
- &channel);
- if (multi_install_ && add_modifier) {
- EXPECT_EQ(L"-m", channel);
- } else {
- EXPECT_EQ(install_static::kChromeChannelStable, channel);
- }
-
- SetChannelName(L"x64-beta");
- install_static::GetChromeChannelName(!system_level_, add_modifier,
- &channel);
- if (multi_install_ && add_modifier) {
- EXPECT_EQ(L"beta-m", channel);
- } else {
- EXPECT_EQ(install_static::kChromeChannelBeta, channel);
- }
- SetChannelName(L"bar-x64-beta");
- install_static::GetChromeChannelName(!system_level_, add_modifier,
- &channel);
- if (multi_install_ && add_modifier) {
- EXPECT_EQ(L"beta-m", channel);
- } else {
- EXPECT_EQ(install_static::kChromeChannelBeta, channel);
- }
- SetChannelName(L"x64-Beta");
- install_static::GetChromeChannelName(!system_level_, add_modifier,
- &channel);
- if (multi_install_ && add_modifier) {
- EXPECT_EQ(L"beta-m", channel);
- } else {
- EXPECT_EQ(install_static::kChromeChannelBeta, channel);
- }
-
- SetChannelName(L"x64-stable");
- install_static::GetChromeChannelName(!system_level_, add_modifier,
- &channel);
- if (multi_install_ && add_modifier) {
- EXPECT_EQ(L"-m", channel);
- } else {
- EXPECT_EQ(install_static::kChromeChannelStable, channel);
- }
- SetChannelName(L"baz-x64-stable");
- install_static::GetChromeChannelName(!system_level_, add_modifier,
- &channel);
- if (multi_install_ && add_modifier) {
- EXPECT_EQ(L"-m", channel);
- } else {
- EXPECT_EQ(install_static::kChromeChannelStable, channel);
- }
- SetChannelName(L"x64-Stable");
- install_static::GetChromeChannelName(!system_level_, add_modifier,
- &channel);
- if (multi_install_ && add_modifier) {
- EXPECT_EQ(L"-m", channel);
- } else {
- EXPECT_EQ(install_static::kChromeChannelStable, channel);
- }
-
- SetChannelName(L"fuzzy");
- install_static::GetChromeChannelName(!system_level_, add_modifier,
- &channel);
- if (multi_install_ && add_modifier) {
- EXPECT_EQ(L"-m", channel);
- } else {
- EXPECT_EQ(install_static::kChromeChannelStable, channel);
- }
- SetChannelName(L"foo");
- install_static::GetChromeChannelName(!system_level_, add_modifier,
- &channel);
- if (multi_install_ && add_modifier) {
- EXPECT_EQ(L"-m", channel);
- } else {
- EXPECT_EQ(install_static::kChromeChannelStable, channel);
- }
- }
-
const wchar_t* app_guid_;
const wchar_t* chrome_path_;
bool system_level_;
@@ -341,26 +138,26 @@
}
TEST_P(ChromeElfUtilTest, UsageStatsAbsent) {
- EXPECT_FALSE(GetCollectStatsConsentForTesting(chrome_path_));
+ EXPECT_FALSE(AreUsageStatsEnabled(chrome_path_));
}
TEST_P(ChromeElfUtilTest, UsageStatsZero) {
SetUsageStat(0, false);
- EXPECT_FALSE(GetCollectStatsConsentForTesting(chrome_path_));
+ EXPECT_FALSE(AreUsageStatsEnabled(chrome_path_));
}
TEST_P(ChromeElfUtilTest, UsageStatsOne) {
SetUsageStat(1, false);
- EXPECT_TRUE(GetCollectStatsConsentForTesting(chrome_path_));
+ EXPECT_TRUE(AreUsageStatsEnabled(chrome_path_));
if (is_canary_) {
- EXPECT_FALSE(GetCollectStatsConsentForTesting(kChromeUserExePath));
- EXPECT_FALSE(GetCollectStatsConsentForTesting(kChromeSystemExePath));
+ EXPECT_FALSE(AreUsageStatsEnabled(kChromeUserExePath));
+ EXPECT_FALSE(AreUsageStatsEnabled(kChromeSystemExePath));
} else if (system_level_) {
- EXPECT_FALSE(GetCollectStatsConsentForTesting(kCanaryExePath));
- EXPECT_FALSE(GetCollectStatsConsentForTesting(kChromeUserExePath));
+ EXPECT_FALSE(AreUsageStatsEnabled(kCanaryExePath));
+ EXPECT_FALSE(AreUsageStatsEnabled(kChromeUserExePath));
} else {
- EXPECT_FALSE(GetCollectStatsConsentForTesting(kCanaryExePath));
- EXPECT_FALSE(GetCollectStatsConsentForTesting(kChromeSystemExePath));
+ EXPECT_FALSE(AreUsageStatsEnabled(kCanaryExePath));
+ EXPECT_FALSE(AreUsageStatsEnabled(kChromeSystemExePath));
}
}
@@ -368,26 +165,16 @@
if (!system_level_)
return;
SetUsageStat(0, true);
- EXPECT_FALSE(GetCollectStatsConsentForTesting(chrome_path_));
+ EXPECT_FALSE(AreUsageStatsEnabled(chrome_path_));
}
TEST_P(ChromeElfUtilTest, UsageStatsOneInStateMedium) {
if (!system_level_)
return;
SetUsageStat(1, true);
- EXPECT_TRUE(GetCollectStatsConsentForTesting(chrome_path_));
- EXPECT_FALSE(GetCollectStatsConsentForTesting(kCanaryExePath));
- EXPECT_FALSE(GetCollectStatsConsentForTesting(kChromeUserExePath));
-}
-
-// TODO(ananta)
-// Move this to install_static_unittests.
-// http://crbug.com/604923
-// This test tests the install_static::GetChromeChannelName function and is
-// based on the ChannelInfoTest.Channels in channel_info_unittest.cc
-TEST_P(ChromeElfUtilTest, InstallStaticGetChannelNameTest) {
- PerformChannelNameTests(true); // add_modifier
- PerformChannelNameTests(false); // !add_modifier
+ EXPECT_TRUE(AreUsageStatsEnabled(chrome_path_));
+ EXPECT_FALSE(AreUsageStatsEnabled(kCanaryExePath));
+ EXPECT_FALSE(AreUsageStatsEnabled(kChromeUserExePath));
}
INSTANTIATE_TEST_CASE_P(Canary, ChromeElfUtilTest,
@@ -399,23 +186,4 @@
testing::Values("user", "system"),
testing::Values("single", "multi")));
-// Tests the MatchPattern function in the install_static library.
-// TODO(ananta)
-// Move this to install_static_unittests.
-// http://crbug.com/604923
-TEST(MiscUtilTest, InstallStaticMatchPattern) {
- EXPECT_TRUE(install_static::MatchPattern(L"", L""));
- EXPECT_TRUE(install_static::MatchPattern(L"", L"*"));
- EXPECT_FALSE(install_static::MatchPattern(L"", L"*a"));
- EXPECT_FALSE(install_static::MatchPattern(L"", L"abc"));
- EXPECT_TRUE(install_static::MatchPattern(L"Hello1234", L"He??o*1*"));
- EXPECT_TRUE(install_static::MatchPattern(L"Foo", L"F*?"));
- EXPECT_TRUE(install_static::MatchPattern(L"Foo", L"F*"));
- EXPECT_FALSE(install_static::MatchPattern(L"Foo", L"F*b"));
- EXPECT_TRUE(install_static::MatchPattern(L"abcd", L"*c*d"));
- EXPECT_TRUE(install_static::MatchPattern(L"abcd", L"*?c*d"));
- EXPECT_FALSE(install_static::MatchPattern(L"abcd", L"abcd*efgh"));
- EXPECT_TRUE(install_static::MatchPattern(L"foobarabc", L"*bar*"));
-}
-
} // namespace
« no previous file with comments | « chrome_elf/chrome_elf_main.cc ('k') | chrome_elf/elf_imports_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698