| Index: chrome/browser/rlz/rlz_unittest.cc
|
| diff --git a/chrome/browser/rlz/rlz_unittest.cc b/chrome/browser/rlz/rlz_unittest.cc
|
| index f78a1d9416f7c7081c250d281c5f371e060db239..2b09959ea3655b32b7f39e266ae38113fe91f03a 100644
|
| --- a/chrome/browser/rlz/rlz_unittest.cc
|
| +++ b/chrome/browser/rlz/rlz_unittest.cc
|
| @@ -37,8 +37,10 @@ namespace {
|
| // Dummy RLZ string for the access points.
|
| const char kOmniboxRlzString[] = "test_omnibox";
|
| const char kHomepageRlzString[] = "test_homepage";
|
| +const char kAppListRlzString[] = "test_applist";
|
| const char kNewOmniboxRlzString[] = "new_omnibox";
|
| const char kNewHomepageRlzString[] = "new_homepage";
|
| +const char kNewAppListRlzString[] = "new_applist";
|
|
|
| // Some helper macros to test it a string contains/does not contain a substring.
|
|
|
| @@ -145,6 +147,8 @@ class TestRLZTracker : public RLZTracker {
|
| kNewOmniboxRlzString);
|
| rlz_lib::SetAccessPointRlz(RLZTracker::CHROME_HOME_PAGE,
|
| kNewHomepageRlzString);
|
| + rlz_lib::SetAccessPointRlz(RLZTracker::CHROME_APP_LIST,
|
| + kNewAppListRlzString);
|
| return true;
|
| }
|
|
|
| @@ -166,6 +170,7 @@ class RlzLibTest : public RlzLibTestNoMachineState {
|
|
|
| void SimulateOmniboxUsage();
|
| void SimulateHomepageUsage();
|
| + void SimulateAppListUsage();
|
| void InvokeDelayedInit();
|
|
|
| void ExpectEventRecorded(const char* event_name, bool expected);
|
| @@ -239,6 +244,10 @@ void RlzLibTest::SimulateHomepageUsage() {
|
| content::Details<NavigationEntry>(entry.get()));
|
| }
|
|
|
| +void RlzLibTest::SimulateAppListUsage() {
|
| + RLZTracker::RecordAppListSearch();
|
| +}
|
| +
|
| void RlzLibTest::InvokeDelayedInit() {
|
| tracker_.DelayedInit();
|
| }
|
| @@ -274,6 +283,7 @@ void RlzLibTest::ExpectReactivationRlzPingSent(bool expected) {
|
| // I: the RLZTracker::DelayedInit() method is invoked
|
| // X: the user performs a search using the omnibox
|
| // Y: the user performs a search using the home page
|
| +// Z: the user performs a search using the app list
|
| //
|
| // The events A to D happen in chronological order, but the other events
|
| // may happen at any point between A-B or C-D, in no particular order.
|
| @@ -282,14 +292,17 @@ void RlzLibTest::ExpectReactivationRlzPingSent(bool expected) {
|
| //
|
| // C1I event is recorded
|
| // C2I event is recorded
|
| +// C7I event is recorded
|
| // C1F event is recorded
|
| // C2F event is recorded
|
| +// C7F event is recorded
|
| // C1S event is recorded
|
| // C2S event is recorded
|
| +// C7S event is recorded
|
| // RLZ ping sent
|
| //
|
| -// On Mac, C5 / C6 are sent instead of C1 / C2.
|
| -// On ChromeOS, CA / CB are sent, respectively.
|
| +// On Mac, C5 / C6 / C8 are sent instead of C1 / C2 / C7.
|
| +// On ChromeOS, CA / CB / CC are sent, respectively.
|
| //
|
| // Variations on the above scenarios:
|
| //
|
| @@ -306,6 +319,10 @@ const char kOmniboxFirstSearch[] = "C1F";
|
| const char kHomepageInstall[] = "C2I";
|
| const char kHomepageSetToGoogle[] = "C2S";
|
| const char kHomepageFirstSeach[] = "C2F";
|
| +
|
| +const char kAppListInstall[] = "C7I";
|
| +const char kAppListSetToGoogle[] = "C7S";
|
| +const char kAppListFirstSearch[] = "C7F";
|
| #elif defined(OS_MACOSX)
|
| const char kOmniboxInstall[] = "C5I";
|
| const char kOmniboxSetToGoogle[] = "C5S";
|
| @@ -314,6 +331,10 @@ const char kOmniboxFirstSearch[] = "C5F";
|
| const char kHomepageInstall[] = "C6I";
|
| const char kHomepageSetToGoogle[] = "C6S";
|
| const char kHomepageFirstSeach[] = "C6F";
|
| +
|
| +const char kAppListInstall[] = "C8I";
|
| +const char kAppListSetToGoogle[] = "C8S";
|
| +const char kAppListFirstSearch[] = "C8F";
|
| #elif defined(OS_CHROMEOS)
|
| const char kOmniboxInstall[] = "CAI";
|
| const char kOmniboxSetToGoogle[] = "CAS";
|
| @@ -322,6 +343,10 @@ const char kOmniboxFirstSearch[] = "CAF";
|
| const char kHomepageInstall[] = "CBI";
|
| const char kHomepageSetToGoogle[] = "CBS";
|
| const char kHomepageFirstSeach[] = "CBF";
|
| +
|
| +const char kAppListInstall[] = "CCI";
|
| +const char kAppListSetToGoogle[] = "CCS";
|
| +const char kAppListFirstSearch[] = "CCF";
|
| #endif
|
|
|
| const base::TimeDelta kDelay = base::TimeDelta::FromMilliseconds(20);
|
| @@ -346,6 +371,11 @@ TEST_F(RlzLibTest, QuickStopAfterStart) {
|
| ExpectEventRecorded(kHomepageSetToGoogle, false);
|
| ExpectEventRecorded(kHomepageFirstSeach, false);
|
|
|
| + // App list events.
|
| + ExpectEventRecorded(kAppListInstall, false);
|
| + ExpectEventRecorded(kAppListSetToGoogle, false);
|
| + ExpectEventRecorded(kAppListFirstSearch, false);
|
| +
|
| ExpectRlzPingSent(false);
|
| }
|
|
|
| @@ -363,6 +393,11 @@ TEST_F(RlzLibTest, DelayedInitOnly) {
|
| ExpectEventRecorded(kHomepageSetToGoogle, true);
|
| ExpectEventRecorded(kHomepageFirstSeach, false);
|
|
|
| + // App list events.
|
| + ExpectEventRecorded(kAppListInstall, true);
|
| + ExpectEventRecorded(kAppListSetToGoogle, true);
|
| + ExpectEventRecorded(kAppListFirstSearch, false);
|
| +
|
| ExpectRlzPingSent(true);
|
| }
|
|
|
| @@ -380,6 +415,11 @@ TEST_F(RlzLibTest, DelayedInitOnlyGoogleAsStartup) {
|
| ExpectEventRecorded(kHomepageSetToGoogle, true);
|
| ExpectEventRecorded(kHomepageFirstSeach, true);
|
|
|
| + // App list events.
|
| + ExpectEventRecorded(kAppListInstall, true);
|
| + ExpectEventRecorded(kAppListSetToGoogle, false);
|
| + ExpectEventRecorded(kAppListFirstSearch, false);
|
| +
|
| ExpectRlzPingSent(true);
|
| }
|
|
|
| @@ -397,6 +437,11 @@ TEST_F(RlzLibTest, DelayedInitOnlyNoFirstRunNoRlzStrings) {
|
| ExpectEventRecorded(kHomepageSetToGoogle, true);
|
| ExpectEventRecorded(kHomepageFirstSeach, false);
|
|
|
| + // App list events.
|
| + ExpectEventRecorded(kAppListInstall, true);
|
| + ExpectEventRecorded(kAppListSetToGoogle, true);
|
| + ExpectEventRecorded(kAppListFirstSearch, false);
|
| +
|
| ExpectRlzPingSent(true);
|
| }
|
|
|
| @@ -414,6 +459,11 @@ TEST_F(RlzLibTest, DelayedInitOnlyNoFirstRunNoRlzStringsGoogleAsStartup) {
|
| ExpectEventRecorded(kHomepageSetToGoogle, true);
|
| ExpectEventRecorded(kHomepageFirstSeach, true);
|
|
|
| + // App list events.
|
| + ExpectEventRecorded(kAppListInstall, true);
|
| + ExpectEventRecorded(kAppListSetToGoogle, false);
|
| + ExpectEventRecorded(kAppListFirstSearch, false);
|
| +
|
| ExpectRlzPingSent(true);
|
| }
|
|
|
| @@ -422,6 +472,7 @@ TEST_F(RlzLibTest, DelayedInitOnlyNoFirstRun) {
|
| // performed a successful ping to the RLZ server.
|
| rlz_lib::SetAccessPointRlz(RLZTracker::CHROME_OMNIBOX, kOmniboxRlzString);
|
| rlz_lib::SetAccessPointRlz(RLZTracker::CHROME_HOME_PAGE, kHomepageRlzString);
|
| + rlz_lib::SetAccessPointRlz(RLZTracker::CHROME_APP_LIST, kAppListRlzString);
|
|
|
| TestRLZTracker::InitRlzDelayed(false, false, kDelay, true, true, true);
|
| InvokeDelayedInit();
|
| @@ -436,6 +487,11 @@ TEST_F(RlzLibTest, DelayedInitOnlyNoFirstRun) {
|
| ExpectEventRecorded(kHomepageSetToGoogle, false);
|
| ExpectEventRecorded(kHomepageFirstSeach, true);
|
|
|
| + // App list events.
|
| + ExpectEventRecorded(kAppListInstall, true);
|
| + ExpectEventRecorded(kAppListSetToGoogle, false);
|
| + ExpectEventRecorded(kAppListFirstSearch, false);
|
| +
|
| ExpectRlzPingSent(true);
|
| }
|
|
|
| @@ -453,6 +509,11 @@ TEST_F(RlzLibTest, DelayedInitOnlyNoGoogleDefaultSearchOrHomepageOrStartup) {
|
| ExpectEventRecorded(kHomepageSetToGoogle, false);
|
| ExpectEventRecorded(kHomepageFirstSeach, false);
|
|
|
| + // App list events.
|
| + ExpectEventRecorded(kAppListInstall, true);
|
| + ExpectEventRecorded(kAppListSetToGoogle, false);
|
| + ExpectEventRecorded(kAppListFirstSearch, false);
|
| +
|
| ExpectRlzPingSent(true);
|
| }
|
|
|
| @@ -470,6 +531,11 @@ TEST_F(RlzLibTest, OmniboxUsageOnly) {
|
| ExpectEventRecorded(kHomepageSetToGoogle, false);
|
| ExpectEventRecorded(kHomepageFirstSeach, false);
|
|
|
| + // App list events.
|
| + ExpectEventRecorded(kAppListInstall, false);
|
| + ExpectEventRecorded(kAppListSetToGoogle, false);
|
| + ExpectEventRecorded(kAppListFirstSearch, false);
|
| +
|
| ExpectRlzPingSent(false);
|
| }
|
|
|
| @@ -487,6 +553,33 @@ TEST_F(RlzLibTest, HomepageUsageOnly) {
|
| ExpectEventRecorded(kHomepageSetToGoogle, false);
|
| ExpectEventRecorded(kHomepageFirstSeach, true);
|
|
|
| + // App list events.
|
| + ExpectEventRecorded(kAppListInstall, false);
|
| + ExpectEventRecorded(kAppListSetToGoogle, false);
|
| + ExpectEventRecorded(kAppListFirstSearch, false);
|
| +
|
| + ExpectRlzPingSent(false);
|
| +}
|
| +
|
| +TEST_F(RlzLibTest, AppListUsageOnly) {
|
| + TestRLZTracker::InitRlzDelayed(true, false, kDelay, true, true, false);
|
| + SimulateAppListUsage();
|
| +
|
| + // Omnibox events.
|
| + ExpectEventRecorded(kOmniboxInstall, false);
|
| + ExpectEventRecorded(kOmniboxSetToGoogle, false);
|
| + ExpectEventRecorded(kOmniboxFirstSearch, false);
|
| +
|
| + // Home page events.
|
| + ExpectEventRecorded(kHomepageInstall, false);
|
| + ExpectEventRecorded(kHomepageSetToGoogle, false);
|
| + ExpectEventRecorded(kHomepageFirstSeach, false);
|
| +
|
| + // App list events.
|
| + ExpectEventRecorded(kAppListInstall, false);
|
| + ExpectEventRecorded(kAppListSetToGoogle, false);
|
| + ExpectEventRecorded(kAppListFirstSearch, true);
|
| +
|
| ExpectRlzPingSent(false);
|
| }
|
|
|
| @@ -494,6 +587,7 @@ TEST_F(RlzLibTest, UsageBeforeDelayedInit) {
|
| TestRLZTracker::InitRlzDelayed(true, false, kDelay, true, true, false);
|
| SimulateOmniboxUsage();
|
| SimulateHomepageUsage();
|
| + SimulateAppListUsage();
|
| InvokeDelayedInit();
|
|
|
| // Omnibox events.
|
| @@ -506,14 +600,20 @@ TEST_F(RlzLibTest, UsageBeforeDelayedInit) {
|
| ExpectEventRecorded(kHomepageSetToGoogle, true);
|
| ExpectEventRecorded(kHomepageFirstSeach, true);
|
|
|
| + // App list events.
|
| + ExpectEventRecorded(kAppListInstall, true);
|
| + ExpectEventRecorded(kAppListSetToGoogle, true);
|
| + ExpectEventRecorded(kAppListFirstSearch, true);
|
| +
|
| ExpectRlzPingSent(true);
|
| }
|
|
|
| -TEST_F(RlzLibTest, OmniboxUsageAfterDelayedInit) {
|
| +TEST_F(RlzLibTest, UsageAfterDelayedInit) {
|
| TestRLZTracker::InitRlzDelayed(true, false, kDelay, true, true, false);
|
| InvokeDelayedInit();
|
| SimulateOmniboxUsage();
|
| SimulateHomepageUsage();
|
| + SimulateAppListUsage();
|
|
|
| // Omnibox events.
|
| ExpectEventRecorded(kOmniboxInstall, true);
|
| @@ -525,6 +625,11 @@ TEST_F(RlzLibTest, OmniboxUsageAfterDelayedInit) {
|
| ExpectEventRecorded(kHomepageSetToGoogle, true);
|
| ExpectEventRecorded(kHomepageFirstSeach, true);
|
|
|
| + // App list events.
|
| + ExpectEventRecorded(kAppListInstall, true);
|
| + ExpectEventRecorded(kAppListSetToGoogle, true);
|
| + ExpectEventRecorded(kAppListFirstSearch, true);
|
| +
|
| ExpectRlzPingSent(true);
|
| }
|
|
|
| @@ -542,6 +647,11 @@ TEST_F(RlzLibTest, OmniboxUsageSendsPingWhenSendPingImmediately) {
|
| ExpectEventRecorded(kHomepageSetToGoogle, true);
|
| ExpectEventRecorded(kHomepageFirstSeach, false);
|
|
|
| + // App list events.
|
| + ExpectEventRecorded(kAppListInstall, true);
|
| + ExpectEventRecorded(kAppListSetToGoogle, true);
|
| + ExpectEventRecorded(kAppListFirstSearch, false);
|
| +
|
| ExpectRlzPingSent(true);
|
| }
|
|
|
| @@ -559,6 +669,11 @@ TEST_F(RlzLibTest, HomepageUsageDoesNotSendPingWhenSendPingImmediately) {
|
| ExpectEventRecorded(kHomepageSetToGoogle, false);
|
| ExpectEventRecorded(kHomepageFirstSeach, true);
|
|
|
| + // App list events.
|
| + ExpectEventRecorded(kAppListInstall, false);
|
| + ExpectEventRecorded(kAppListSetToGoogle, false);
|
| + ExpectEventRecorded(kAppListFirstSearch, false);
|
| +
|
| ExpectRlzPingSent(false);
|
| }
|
|
|
| @@ -576,6 +691,33 @@ TEST_F(RlzLibTest, StartupUsageDoesNotSendPingWhenSendPingImmediately) {
|
| ExpectEventRecorded(kHomepageSetToGoogle, false);
|
| ExpectEventRecorded(kHomepageFirstSeach, true);
|
|
|
| + // App list events.
|
| + ExpectEventRecorded(kAppListInstall, false);
|
| + ExpectEventRecorded(kAppListSetToGoogle, false);
|
| + ExpectEventRecorded(kAppListFirstSearch, false);
|
| +
|
| + ExpectRlzPingSent(false);
|
| +}
|
| +
|
| +TEST_F(RlzLibTest, AppListUsageDoesNotSendPingWhenSendPingImmediately) {
|
| + TestRLZTracker::InitRlzDelayed(true, true, kDelay, true, false, false);
|
| + SimulateAppListUsage();
|
| +
|
| + // Omnibox events.
|
| + ExpectEventRecorded(kOmniboxInstall, false);
|
| + ExpectEventRecorded(kOmniboxSetToGoogle, false);
|
| + ExpectEventRecorded(kOmniboxFirstSearch, false);
|
| +
|
| + // Home page events.
|
| + ExpectEventRecorded(kHomepageInstall, false);
|
| + ExpectEventRecorded(kHomepageSetToGoogle, false);
|
| + ExpectEventRecorded(kHomepageFirstSeach, false);
|
| +
|
| + // App list events.
|
| + ExpectEventRecorded(kAppListInstall, false);
|
| + ExpectEventRecorded(kAppListSetToGoogle, false);
|
| + ExpectEventRecorded(kAppListFirstSearch, true);
|
| +
|
| ExpectRlzPingSent(false);
|
| }
|
|
|
| @@ -622,6 +764,7 @@ TEST_F(RlzLibTest, PingUpdatesRlzCache) {
|
| // Set dummy RLZ string.
|
| rlz_lib::SetAccessPointRlz(RLZTracker::CHROME_OMNIBOX, kOmniboxRlzString);
|
| rlz_lib::SetAccessPointRlz(RLZTracker::CHROME_HOME_PAGE, kHomepageRlzString);
|
| + rlz_lib::SetAccessPointRlz(RLZTracker::CHROME_APP_LIST, kAppListRlzString);
|
|
|
| base::string16 rlz;
|
|
|
| @@ -633,6 +776,8 @@ TEST_F(RlzLibTest, PingUpdatesRlzCache) {
|
| EXPECT_TRUE(RLZTracker::GetAccessPointRlz(
|
| RLZTracker::CHROME_HOME_PAGE, &rlz));
|
| EXPECT_STREQ(kHomepageRlzString, base::UTF16ToUTF8(rlz).c_str());
|
| + EXPECT_TRUE(RLZTracker::GetAccessPointRlz(RLZTracker::CHROME_APP_LIST, &rlz));
|
| + EXPECT_STREQ(kAppListRlzString, base::UTF16ToUTF8(rlz).c_str());
|
|
|
| // Make sure cache is valid.
|
| tracker_.set_assume_not_ui_thread(false);
|
| @@ -642,6 +787,8 @@ TEST_F(RlzLibTest, PingUpdatesRlzCache) {
|
| EXPECT_TRUE(RLZTracker::GetAccessPointRlz(
|
| RLZTracker::CHROME_HOME_PAGE, &rlz));
|
| EXPECT_STREQ(kHomepageRlzString, base::UTF16ToUTF8(rlz).c_str());
|
| + EXPECT_TRUE(RLZTracker::GetAccessPointRlz(RLZTracker::CHROME_APP_LIST, &rlz));
|
| + EXPECT_STREQ(kAppListRlzString, base::UTF16ToUTF8(rlz).c_str());
|
|
|
| // Perform ping.
|
| tracker_.set_assume_not_ui_thread(true);
|
| @@ -657,6 +804,8 @@ TEST_F(RlzLibTest, PingUpdatesRlzCache) {
|
| EXPECT_TRUE(RLZTracker::GetAccessPointRlz(
|
| RLZTracker::CHROME_HOME_PAGE, &rlz));
|
| EXPECT_STREQ(kNewHomepageRlzString, base::UTF16ToUTF8(rlz).c_str());
|
| + EXPECT_TRUE(RLZTracker::GetAccessPointRlz(RLZTracker::CHROME_APP_LIST, &rlz));
|
| + EXPECT_STREQ(kNewAppListRlzString, base::UTF16ToUTF8(rlz).c_str());
|
| }
|
|
|
| TEST_F(RlzLibTest, ObserveHandlesBadArgs) {
|
|
|