| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/rlz/rlz.h" | 5 #include "chrome/browser/rlz/rlz.h" |
| 6 | 6 |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/browser/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
| 10 #include "chrome/browser/google/google_util.h" | 10 #include "chrome/browser/google/google_util.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 | 30 |
| 31 #if defined(OS_WIN) | 31 #if defined(OS_WIN) |
| 32 using base::win::RegKey; | 32 using base::win::RegKey; |
| 33 #endif | 33 #endif |
| 34 | 34 |
| 35 namespace { | 35 namespace { |
| 36 | 36 |
| 37 // Dummy RLZ string for the access points. | 37 // Dummy RLZ string for the access points. |
| 38 const char kOmniboxRlzString[] = "test_omnibox"; | 38 const char kOmniboxRlzString[] = "test_omnibox"; |
| 39 const char kHomepageRlzString[] = "test_homepage"; | 39 const char kHomepageRlzString[] = "test_homepage"; |
| 40 const char kAppListRlzString[] = "test_applist"; |
| 40 const char kNewOmniboxRlzString[] = "new_omnibox"; | 41 const char kNewOmniboxRlzString[] = "new_omnibox"; |
| 41 const char kNewHomepageRlzString[] = "new_homepage"; | 42 const char kNewHomepageRlzString[] = "new_homepage"; |
| 43 const char kNewAppListRlzString[] = "new_applist"; |
| 42 | 44 |
| 43 // Some helper macros to test it a string contains/does not contain a substring. | 45 // Some helper macros to test it a string contains/does not contain a substring. |
| 44 | 46 |
| 45 AssertionResult CmpHelperSTRC(const char* str_expression, | 47 AssertionResult CmpHelperSTRC(const char* str_expression, |
| 46 const char* substr_expression, | 48 const char* substr_expression, |
| 47 const char* str, | 49 const char* str, |
| 48 const char* substr) { | 50 const char* substr) { |
| 49 if (NULL != strstr(str, substr)) { | 51 if (NULL != strstr(str, substr)) { |
| 50 return AssertionSuccess(); | 52 return AssertionSuccess(); |
| 51 } | 53 } |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 // Don't ping the server during tests, just pretend as if we did. | 140 // Don't ping the server during tests, just pretend as if we did. |
| 139 EXPECT_FALSE(brand.empty()); | 141 EXPECT_FALSE(brand.empty()); |
| 140 pinged_brands_.insert(brand); | 142 pinged_brands_.insert(brand); |
| 141 | 143 |
| 142 // Set new access points RLZ string, like the actual server ping would have | 144 // Set new access points RLZ string, like the actual server ping would have |
| 143 // done. | 145 // done. |
| 144 rlz_lib::SetAccessPointRlz(RLZTracker::CHROME_OMNIBOX, | 146 rlz_lib::SetAccessPointRlz(RLZTracker::CHROME_OMNIBOX, |
| 145 kNewOmniboxRlzString); | 147 kNewOmniboxRlzString); |
| 146 rlz_lib::SetAccessPointRlz(RLZTracker::CHROME_HOME_PAGE, | 148 rlz_lib::SetAccessPointRlz(RLZTracker::CHROME_HOME_PAGE, |
| 147 kNewHomepageRlzString); | 149 kNewHomepageRlzString); |
| 150 rlz_lib::SetAccessPointRlz(RLZTracker::CHROME_APP_LIST, |
| 151 kNewAppListRlzString); |
| 148 return true; | 152 return true; |
| 149 } | 153 } |
| 150 | 154 |
| 151 std::set<std::string> pinged_brands_; | 155 std::set<std::string> pinged_brands_; |
| 152 bool assume_not_ui_thread_; | 156 bool assume_not_ui_thread_; |
| 153 | 157 |
| 154 DISALLOW_COPY_AND_ASSIGN(TestRLZTracker); | 158 DISALLOW_COPY_AND_ASSIGN(TestRLZTracker); |
| 155 }; | 159 }; |
| 156 | 160 |
| 157 class RlzLibTest : public RlzLibTestNoMachineState { | 161 class RlzLibTest : public RlzLibTestNoMachineState { |
| 158 protected: | 162 protected: |
| 159 virtual void SetUp() OVERRIDE; | 163 virtual void SetUp() OVERRIDE; |
| 160 | 164 |
| 161 void SetMainBrand(const char* brand); | 165 void SetMainBrand(const char* brand); |
| 162 void SetReactivationBrand(const char* brand); | 166 void SetReactivationBrand(const char* brand); |
| 163 #if defined(OS_WIN) | 167 #if defined(OS_WIN) |
| 164 void SetRegistryBrandValue(const wchar_t* name, const char* brand); | 168 void SetRegistryBrandValue(const wchar_t* name, const char* brand); |
| 165 #endif | 169 #endif |
| 166 | 170 |
| 167 void SimulateOmniboxUsage(); | 171 void SimulateOmniboxUsage(); |
| 168 void SimulateHomepageUsage(); | 172 void SimulateHomepageUsage(); |
| 173 void SimulateAppListUsage(); |
| 169 void InvokeDelayedInit(); | 174 void InvokeDelayedInit(); |
| 170 | 175 |
| 171 void ExpectEventRecorded(const char* event_name, bool expected); | 176 void ExpectEventRecorded(const char* event_name, bool expected); |
| 172 void ExpectRlzPingSent(bool expected); | 177 void ExpectRlzPingSent(bool expected); |
| 173 void ExpectReactivationRlzPingSent(bool expected); | 178 void ExpectReactivationRlzPingSent(bool expected); |
| 174 | 179 |
| 175 TestRLZTracker tracker_; | 180 TestRLZTracker tracker_; |
| 176 #if defined(OS_POSIX) | 181 #if defined(OS_POSIX) |
| 177 scoped_ptr<google_util::BrandForTesting> brand_override_; | 182 scoped_ptr<google_util::BrandForTesting> brand_override_; |
| 178 #endif | 183 #endif |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 | 237 |
| 233 void RlzLibTest::SimulateHomepageUsage() { | 238 void RlzLibTest::SimulateHomepageUsage() { |
| 234 scoped_ptr<NavigationEntry> entry(NavigationEntry::Create()); | 239 scoped_ptr<NavigationEntry> entry(NavigationEntry::Create()); |
| 235 entry->SetPageID(0); | 240 entry->SetPageID(0); |
| 236 entry->SetTransitionType(content::PAGE_TRANSITION_HOME_PAGE); | 241 entry->SetTransitionType(content::PAGE_TRANSITION_HOME_PAGE); |
| 237 tracker_.Observe(content::NOTIFICATION_NAV_ENTRY_PENDING, | 242 tracker_.Observe(content::NOTIFICATION_NAV_ENTRY_PENDING, |
| 238 content::NotificationService::AllSources(), | 243 content::NotificationService::AllSources(), |
| 239 content::Details<NavigationEntry>(entry.get())); | 244 content::Details<NavigationEntry>(entry.get())); |
| 240 } | 245 } |
| 241 | 246 |
| 247 void RlzLibTest::SimulateAppListUsage() { |
| 248 RLZTracker::RecordAppListSearch(); |
| 249 } |
| 250 |
| 242 void RlzLibTest::InvokeDelayedInit() { | 251 void RlzLibTest::InvokeDelayedInit() { |
| 243 tracker_.DelayedInit(); | 252 tracker_.DelayedInit(); |
| 244 } | 253 } |
| 245 | 254 |
| 246 void RlzLibTest::ExpectEventRecorded(const char* event_name, bool expected) { | 255 void RlzLibTest::ExpectEventRecorded(const char* event_name, bool expected) { |
| 247 char cgi[rlz_lib::kMaxCgiLength]; | 256 char cgi[rlz_lib::kMaxCgiLength]; |
| 248 GetProductEventsAsCgi(rlz_lib::CHROME, cgi, arraysize(cgi)); | 257 GetProductEventsAsCgi(rlz_lib::CHROME, cgi, arraysize(cgi)); |
| 249 if (expected) { | 258 if (expected) { |
| 250 EXPECT_STR_CONTAINS(cgi, event_name); | 259 EXPECT_STR_CONTAINS(cgi, event_name); |
| 251 } else { | 260 } else { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 267 | 276 |
| 268 // The events that affect the different RLZ scenarios are the following: | 277 // The events that affect the different RLZ scenarios are the following: |
| 269 // | 278 // |
| 270 // A: the user starts chrome for the first time | 279 // A: the user starts chrome for the first time |
| 271 // B: the user stops chrome | 280 // B: the user stops chrome |
| 272 // C: the user start a subsequent time | 281 // C: the user start a subsequent time |
| 273 // D: the user stops chrome again | 282 // D: the user stops chrome again |
| 274 // I: the RLZTracker::DelayedInit() method is invoked | 283 // I: the RLZTracker::DelayedInit() method is invoked |
| 275 // X: the user performs a search using the omnibox | 284 // X: the user performs a search using the omnibox |
| 276 // Y: the user performs a search using the home page | 285 // Y: the user performs a search using the home page |
| 286 // Z: the user performs a search using the app list |
| 277 // | 287 // |
| 278 // The events A to D happen in chronological order, but the other events | 288 // The events A to D happen in chronological order, but the other events |
| 279 // may happen at any point between A-B or C-D, in no particular order. | 289 // may happen at any point between A-B or C-D, in no particular order. |
| 280 // | 290 // |
| 281 // The visible results of the scenarios on Win are: | 291 // The visible results of the scenarios on Win are: |
| 282 // | 292 // |
| 283 // C1I event is recorded | 293 // C1I event is recorded |
| 284 // C2I event is recorded | 294 // C2I event is recorded |
| 295 // C7I event is recorded |
| 285 // C1F event is recorded | 296 // C1F event is recorded |
| 286 // C2F event is recorded | 297 // C2F event is recorded |
| 298 // C7F event is recorded |
| 287 // C1S event is recorded | 299 // C1S event is recorded |
| 288 // C2S event is recorded | 300 // C2S event is recorded |
| 301 // C7S event is recorded |
| 289 // RLZ ping sent | 302 // RLZ ping sent |
| 290 // | 303 // |
| 291 // On Mac, C5 / C6 are sent instead of C1 / C2. | 304 // On Mac, C5 / C6 / C8 are sent instead of C1 / C2 / C7. |
| 292 // On ChromeOS, CA / CB are sent, respectively. | 305 // On ChromeOS, CA / CB / CC are sent, respectively. |
| 293 // | 306 // |
| 294 // Variations on the above scenarios: | 307 // Variations on the above scenarios: |
| 295 // | 308 // |
| 296 // - if the delay specified to InitRlzDelayed() is negative, then the RLZ | 309 // - if the delay specified to InitRlzDelayed() is negative, then the RLZ |
| 297 // ping should be sent out at the time of event X and not wait for I | 310 // ping should be sent out at the time of event X and not wait for I |
| 298 // | 311 // |
| 299 // Also want to test that pre-warming the RLZ string cache works correctly. | 312 // Also want to test that pre-warming the RLZ string cache works correctly. |
| 300 | 313 |
| 301 #if defined(OS_WIN) | 314 #if defined(OS_WIN) |
| 302 const char kOmniboxInstall[] = "C1I"; | 315 const char kOmniboxInstall[] = "C1I"; |
| 303 const char kOmniboxSetToGoogle[] = "C1S"; | 316 const char kOmniboxSetToGoogle[] = "C1S"; |
| 304 const char kOmniboxFirstSearch[] = "C1F"; | 317 const char kOmniboxFirstSearch[] = "C1F"; |
| 305 | 318 |
| 306 const char kHomepageInstall[] = "C2I"; | 319 const char kHomepageInstall[] = "C2I"; |
| 307 const char kHomepageSetToGoogle[] = "C2S"; | 320 const char kHomepageSetToGoogle[] = "C2S"; |
| 308 const char kHomepageFirstSeach[] = "C2F"; | 321 const char kHomepageFirstSeach[] = "C2F"; |
| 322 |
| 323 const char kAppListInstall[] = "C7I"; |
| 324 const char kAppListSetToGoogle[] = "C7S"; |
| 325 const char kAppListFirstSearch[] = "C7F"; |
| 309 #elif defined(OS_MACOSX) | 326 #elif defined(OS_MACOSX) |
| 310 const char kOmniboxInstall[] = "C5I"; | 327 const char kOmniboxInstall[] = "C5I"; |
| 311 const char kOmniboxSetToGoogle[] = "C5S"; | 328 const char kOmniboxSetToGoogle[] = "C5S"; |
| 312 const char kOmniboxFirstSearch[] = "C5F"; | 329 const char kOmniboxFirstSearch[] = "C5F"; |
| 313 | 330 |
| 314 const char kHomepageInstall[] = "C6I"; | 331 const char kHomepageInstall[] = "C6I"; |
| 315 const char kHomepageSetToGoogle[] = "C6S"; | 332 const char kHomepageSetToGoogle[] = "C6S"; |
| 316 const char kHomepageFirstSeach[] = "C6F"; | 333 const char kHomepageFirstSeach[] = "C6F"; |
| 334 |
| 335 const char kAppListInstall[] = "C8I"; |
| 336 const char kAppListSetToGoogle[] = "C8S"; |
| 337 const char kAppListFirstSearch[] = "C8F"; |
| 317 #elif defined(OS_CHROMEOS) | 338 #elif defined(OS_CHROMEOS) |
| 318 const char kOmniboxInstall[] = "CAI"; | 339 const char kOmniboxInstall[] = "CAI"; |
| 319 const char kOmniboxSetToGoogle[] = "CAS"; | 340 const char kOmniboxSetToGoogle[] = "CAS"; |
| 320 const char kOmniboxFirstSearch[] = "CAF"; | 341 const char kOmniboxFirstSearch[] = "CAF"; |
| 321 | 342 |
| 322 const char kHomepageInstall[] = "CBI"; | 343 const char kHomepageInstall[] = "CBI"; |
| 323 const char kHomepageSetToGoogle[] = "CBS"; | 344 const char kHomepageSetToGoogle[] = "CBS"; |
| 324 const char kHomepageFirstSeach[] = "CBF"; | 345 const char kHomepageFirstSeach[] = "CBF"; |
| 346 |
| 347 const char kAppListInstall[] = "CCI"; |
| 348 const char kAppListSetToGoogle[] = "CCS"; |
| 349 const char kAppListFirstSearch[] = "CCF"; |
| 325 #endif | 350 #endif |
| 326 | 351 |
| 327 const base::TimeDelta kDelay = base::TimeDelta::FromMilliseconds(20); | 352 const base::TimeDelta kDelay = base::TimeDelta::FromMilliseconds(20); |
| 328 | 353 |
| 329 TEST_F(RlzLibTest, RecordProductEvent) { | 354 TEST_F(RlzLibTest, RecordProductEvent) { |
| 330 RLZTracker::RecordProductEvent(rlz_lib::CHROME, RLZTracker::CHROME_OMNIBOX, | 355 RLZTracker::RecordProductEvent(rlz_lib::CHROME, RLZTracker::CHROME_OMNIBOX, |
| 331 rlz_lib::FIRST_SEARCH); | 356 rlz_lib::FIRST_SEARCH); |
| 332 | 357 |
| 333 ExpectEventRecorded(kOmniboxFirstSearch, true); | 358 ExpectEventRecorded(kOmniboxFirstSearch, true); |
| 334 } | 359 } |
| 335 | 360 |
| 336 TEST_F(RlzLibTest, QuickStopAfterStart) { | 361 TEST_F(RlzLibTest, QuickStopAfterStart) { |
| 337 TestRLZTracker::InitRlzDelayed(true, false, kDelay, true, true, true); | 362 TestRLZTracker::InitRlzDelayed(true, false, kDelay, true, true, true); |
| 338 | 363 |
| 339 // Omnibox events. | 364 // Omnibox events. |
| 340 ExpectEventRecorded(kOmniboxInstall, false); | 365 ExpectEventRecorded(kOmniboxInstall, false); |
| 341 ExpectEventRecorded(kOmniboxSetToGoogle, false); | 366 ExpectEventRecorded(kOmniboxSetToGoogle, false); |
| 342 ExpectEventRecorded(kOmniboxFirstSearch, false); | 367 ExpectEventRecorded(kOmniboxFirstSearch, false); |
| 343 | 368 |
| 344 // Home page events. | 369 // Home page events. |
| 345 ExpectEventRecorded(kHomepageInstall, false); | 370 ExpectEventRecorded(kHomepageInstall, false); |
| 346 ExpectEventRecorded(kHomepageSetToGoogle, false); | 371 ExpectEventRecorded(kHomepageSetToGoogle, false); |
| 347 ExpectEventRecorded(kHomepageFirstSeach, false); | 372 ExpectEventRecorded(kHomepageFirstSeach, false); |
| 348 | 373 |
| 374 // App list events. |
| 375 ExpectEventRecorded(kAppListInstall, false); |
| 376 ExpectEventRecorded(kAppListSetToGoogle, false); |
| 377 ExpectEventRecorded(kAppListFirstSearch, false); |
| 378 |
| 349 ExpectRlzPingSent(false); | 379 ExpectRlzPingSent(false); |
| 350 } | 380 } |
| 351 | 381 |
| 352 TEST_F(RlzLibTest, DelayedInitOnly) { | 382 TEST_F(RlzLibTest, DelayedInitOnly) { |
| 353 TestRLZTracker::InitRlzDelayed(true, false, kDelay, true, true, false); | 383 TestRLZTracker::InitRlzDelayed(true, false, kDelay, true, true, false); |
| 354 InvokeDelayedInit(); | 384 InvokeDelayedInit(); |
| 355 | 385 |
| 356 // Omnibox events. | 386 // Omnibox events. |
| 357 ExpectEventRecorded(kOmniboxInstall, true); | 387 ExpectEventRecorded(kOmniboxInstall, true); |
| 358 ExpectEventRecorded(kOmniboxSetToGoogle, true); | 388 ExpectEventRecorded(kOmniboxSetToGoogle, true); |
| 359 ExpectEventRecorded(kOmniboxFirstSearch, false); | 389 ExpectEventRecorded(kOmniboxFirstSearch, false); |
| 360 | 390 |
| 361 // Home page events. | 391 // Home page events. |
| 362 ExpectEventRecorded(kHomepageInstall, true); | 392 ExpectEventRecorded(kHomepageInstall, true); |
| 363 ExpectEventRecorded(kHomepageSetToGoogle, true); | 393 ExpectEventRecorded(kHomepageSetToGoogle, true); |
| 364 ExpectEventRecorded(kHomepageFirstSeach, false); | 394 ExpectEventRecorded(kHomepageFirstSeach, false); |
| 365 | 395 |
| 396 // App list events. |
| 397 ExpectEventRecorded(kAppListInstall, true); |
| 398 ExpectEventRecorded(kAppListSetToGoogle, true); |
| 399 ExpectEventRecorded(kAppListFirstSearch, false); |
| 400 |
| 366 ExpectRlzPingSent(true); | 401 ExpectRlzPingSent(true); |
| 367 } | 402 } |
| 368 | 403 |
| 369 TEST_F(RlzLibTest, DelayedInitOnlyGoogleAsStartup) { | 404 TEST_F(RlzLibTest, DelayedInitOnlyGoogleAsStartup) { |
| 370 TestRLZTracker::InitRlzDelayed(true, false, kDelay, false, false, true); | 405 TestRLZTracker::InitRlzDelayed(true, false, kDelay, false, false, true); |
| 371 InvokeDelayedInit(); | 406 InvokeDelayedInit(); |
| 372 | 407 |
| 373 // Omnibox events. | 408 // Omnibox events. |
| 374 ExpectEventRecorded(kOmniboxInstall, true); | 409 ExpectEventRecorded(kOmniboxInstall, true); |
| 375 ExpectEventRecorded(kOmniboxSetToGoogle, false); | 410 ExpectEventRecorded(kOmniboxSetToGoogle, false); |
| 376 ExpectEventRecorded(kOmniboxFirstSearch, false); | 411 ExpectEventRecorded(kOmniboxFirstSearch, false); |
| 377 | 412 |
| 378 // Home page events. | 413 // Home page events. |
| 379 ExpectEventRecorded(kHomepageInstall, true); | 414 ExpectEventRecorded(kHomepageInstall, true); |
| 380 ExpectEventRecorded(kHomepageSetToGoogle, true); | 415 ExpectEventRecorded(kHomepageSetToGoogle, true); |
| 381 ExpectEventRecorded(kHomepageFirstSeach, true); | 416 ExpectEventRecorded(kHomepageFirstSeach, true); |
| 382 | 417 |
| 418 // App list events. |
| 419 ExpectEventRecorded(kAppListInstall, true); |
| 420 ExpectEventRecorded(kAppListSetToGoogle, false); |
| 421 ExpectEventRecorded(kAppListFirstSearch, false); |
| 422 |
| 383 ExpectRlzPingSent(true); | 423 ExpectRlzPingSent(true); |
| 384 } | 424 } |
| 385 | 425 |
| 386 TEST_F(RlzLibTest, DelayedInitOnlyNoFirstRunNoRlzStrings) { | 426 TEST_F(RlzLibTest, DelayedInitOnlyNoFirstRunNoRlzStrings) { |
| 387 TestRLZTracker::InitRlzDelayed(false, false, kDelay, true, true, false); | 427 TestRLZTracker::InitRlzDelayed(false, false, kDelay, true, true, false); |
| 388 InvokeDelayedInit(); | 428 InvokeDelayedInit(); |
| 389 | 429 |
| 390 // Omnibox events. | 430 // Omnibox events. |
| 391 ExpectEventRecorded(kOmniboxInstall, true); | 431 ExpectEventRecorded(kOmniboxInstall, true); |
| 392 ExpectEventRecorded(kOmniboxSetToGoogle, true); | 432 ExpectEventRecorded(kOmniboxSetToGoogle, true); |
| 393 ExpectEventRecorded(kOmniboxFirstSearch, false); | 433 ExpectEventRecorded(kOmniboxFirstSearch, false); |
| 394 | 434 |
| 395 // Home page events. | 435 // Home page events. |
| 396 ExpectEventRecorded(kHomepageInstall, true); | 436 ExpectEventRecorded(kHomepageInstall, true); |
| 397 ExpectEventRecorded(kHomepageSetToGoogle, true); | 437 ExpectEventRecorded(kHomepageSetToGoogle, true); |
| 398 ExpectEventRecorded(kHomepageFirstSeach, false); | 438 ExpectEventRecorded(kHomepageFirstSeach, false); |
| 399 | 439 |
| 440 // App list events. |
| 441 ExpectEventRecorded(kAppListInstall, true); |
| 442 ExpectEventRecorded(kAppListSetToGoogle, true); |
| 443 ExpectEventRecorded(kAppListFirstSearch, false); |
| 444 |
| 400 ExpectRlzPingSent(true); | 445 ExpectRlzPingSent(true); |
| 401 } | 446 } |
| 402 | 447 |
| 403 TEST_F(RlzLibTest, DelayedInitOnlyNoFirstRunNoRlzStringsGoogleAsStartup) { | 448 TEST_F(RlzLibTest, DelayedInitOnlyNoFirstRunNoRlzStringsGoogleAsStartup) { |
| 404 TestRLZTracker::InitRlzDelayed(false, false, kDelay, false, false, true); | 449 TestRLZTracker::InitRlzDelayed(false, false, kDelay, false, false, true); |
| 405 InvokeDelayedInit(); | 450 InvokeDelayedInit(); |
| 406 | 451 |
| 407 // Omnibox events. | 452 // Omnibox events. |
| 408 ExpectEventRecorded(kOmniboxInstall, true); | 453 ExpectEventRecorded(kOmniboxInstall, true); |
| 409 ExpectEventRecorded(kOmniboxSetToGoogle, false); | 454 ExpectEventRecorded(kOmniboxSetToGoogle, false); |
| 410 ExpectEventRecorded(kOmniboxFirstSearch, false); | 455 ExpectEventRecorded(kOmniboxFirstSearch, false); |
| 411 | 456 |
| 412 // Home page events. | 457 // Home page events. |
| 413 ExpectEventRecorded(kHomepageInstall, true); | 458 ExpectEventRecorded(kHomepageInstall, true); |
| 414 ExpectEventRecorded(kHomepageSetToGoogle, true); | 459 ExpectEventRecorded(kHomepageSetToGoogle, true); |
| 415 ExpectEventRecorded(kHomepageFirstSeach, true); | 460 ExpectEventRecorded(kHomepageFirstSeach, true); |
| 416 | 461 |
| 462 // App list events. |
| 463 ExpectEventRecorded(kAppListInstall, true); |
| 464 ExpectEventRecorded(kAppListSetToGoogle, false); |
| 465 ExpectEventRecorded(kAppListFirstSearch, false); |
| 466 |
| 417 ExpectRlzPingSent(true); | 467 ExpectRlzPingSent(true); |
| 418 } | 468 } |
| 419 | 469 |
| 420 TEST_F(RlzLibTest, DelayedInitOnlyNoFirstRun) { | 470 TEST_F(RlzLibTest, DelayedInitOnlyNoFirstRun) { |
| 421 // Set some dummy RLZ strings to simulate that we already ran before and | 471 // Set some dummy RLZ strings to simulate that we already ran before and |
| 422 // performed a successful ping to the RLZ server. | 472 // performed a successful ping to the RLZ server. |
| 423 rlz_lib::SetAccessPointRlz(RLZTracker::CHROME_OMNIBOX, kOmniboxRlzString); | 473 rlz_lib::SetAccessPointRlz(RLZTracker::CHROME_OMNIBOX, kOmniboxRlzString); |
| 424 rlz_lib::SetAccessPointRlz(RLZTracker::CHROME_HOME_PAGE, kHomepageRlzString); | 474 rlz_lib::SetAccessPointRlz(RLZTracker::CHROME_HOME_PAGE, kHomepageRlzString); |
| 475 rlz_lib::SetAccessPointRlz(RLZTracker::CHROME_APP_LIST, kAppListRlzString); |
| 425 | 476 |
| 426 TestRLZTracker::InitRlzDelayed(false, false, kDelay, true, true, true); | 477 TestRLZTracker::InitRlzDelayed(false, false, kDelay, true, true, true); |
| 427 InvokeDelayedInit(); | 478 InvokeDelayedInit(); |
| 428 | 479 |
| 429 // Omnibox events. | 480 // Omnibox events. |
| 430 ExpectEventRecorded(kOmniboxInstall, true); | 481 ExpectEventRecorded(kOmniboxInstall, true); |
| 431 ExpectEventRecorded(kOmniboxSetToGoogle, false); | 482 ExpectEventRecorded(kOmniboxSetToGoogle, false); |
| 432 ExpectEventRecorded(kOmniboxFirstSearch, false); | 483 ExpectEventRecorded(kOmniboxFirstSearch, false); |
| 433 | 484 |
| 434 // Home page events. | 485 // Home page events. |
| 435 ExpectEventRecorded(kHomepageInstall, true); | 486 ExpectEventRecorded(kHomepageInstall, true); |
| 436 ExpectEventRecorded(kHomepageSetToGoogle, false); | 487 ExpectEventRecorded(kHomepageSetToGoogle, false); |
| 437 ExpectEventRecorded(kHomepageFirstSeach, true); | 488 ExpectEventRecorded(kHomepageFirstSeach, true); |
| 438 | 489 |
| 490 // App list events. |
| 491 ExpectEventRecorded(kAppListInstall, true); |
| 492 ExpectEventRecorded(kAppListSetToGoogle, false); |
| 493 ExpectEventRecorded(kAppListFirstSearch, false); |
| 494 |
| 439 ExpectRlzPingSent(true); | 495 ExpectRlzPingSent(true); |
| 440 } | 496 } |
| 441 | 497 |
| 442 TEST_F(RlzLibTest, DelayedInitOnlyNoGoogleDefaultSearchOrHomepageOrStartup) { | 498 TEST_F(RlzLibTest, DelayedInitOnlyNoGoogleDefaultSearchOrHomepageOrStartup) { |
| 443 TestRLZTracker::InitRlzDelayed(true, false, kDelay, false, false, false); | 499 TestRLZTracker::InitRlzDelayed(true, false, kDelay, false, false, false); |
| 444 InvokeDelayedInit(); | 500 InvokeDelayedInit(); |
| 445 | 501 |
| 446 // Omnibox events. | 502 // Omnibox events. |
| 447 ExpectEventRecorded(kOmniboxInstall, true); | 503 ExpectEventRecorded(kOmniboxInstall, true); |
| 448 ExpectEventRecorded(kOmniboxSetToGoogle, false); | 504 ExpectEventRecorded(kOmniboxSetToGoogle, false); |
| 449 ExpectEventRecorded(kOmniboxFirstSearch, false); | 505 ExpectEventRecorded(kOmniboxFirstSearch, false); |
| 450 | 506 |
| 451 // Home page events. | 507 // Home page events. |
| 452 ExpectEventRecorded(kHomepageInstall, true); | 508 ExpectEventRecorded(kHomepageInstall, true); |
| 453 ExpectEventRecorded(kHomepageSetToGoogle, false); | 509 ExpectEventRecorded(kHomepageSetToGoogle, false); |
| 454 ExpectEventRecorded(kHomepageFirstSeach, false); | 510 ExpectEventRecorded(kHomepageFirstSeach, false); |
| 455 | 511 |
| 512 // App list events. |
| 513 ExpectEventRecorded(kAppListInstall, true); |
| 514 ExpectEventRecorded(kAppListSetToGoogle, false); |
| 515 ExpectEventRecorded(kAppListFirstSearch, false); |
| 516 |
| 456 ExpectRlzPingSent(true); | 517 ExpectRlzPingSent(true); |
| 457 } | 518 } |
| 458 | 519 |
| 459 TEST_F(RlzLibTest, OmniboxUsageOnly) { | 520 TEST_F(RlzLibTest, OmniboxUsageOnly) { |
| 460 TestRLZTracker::InitRlzDelayed(true, false, kDelay, true, true, false); | 521 TestRLZTracker::InitRlzDelayed(true, false, kDelay, true, true, false); |
| 461 SimulateOmniboxUsage(); | 522 SimulateOmniboxUsage(); |
| 462 | 523 |
| 463 // Omnibox events. | 524 // Omnibox events. |
| 464 ExpectEventRecorded(kOmniboxInstall, false); | 525 ExpectEventRecorded(kOmniboxInstall, false); |
| 465 ExpectEventRecorded(kOmniboxSetToGoogle, false); | 526 ExpectEventRecorded(kOmniboxSetToGoogle, false); |
| 466 ExpectEventRecorded(kOmniboxFirstSearch, true); | 527 ExpectEventRecorded(kOmniboxFirstSearch, true); |
| 467 | 528 |
| 468 // Home page events. | 529 // Home page events. |
| 469 ExpectEventRecorded(kHomepageInstall, false); | 530 ExpectEventRecorded(kHomepageInstall, false); |
| 470 ExpectEventRecorded(kHomepageSetToGoogle, false); | 531 ExpectEventRecorded(kHomepageSetToGoogle, false); |
| 471 ExpectEventRecorded(kHomepageFirstSeach, false); | 532 ExpectEventRecorded(kHomepageFirstSeach, false); |
| 472 | 533 |
| 534 // App list events. |
| 535 ExpectEventRecorded(kAppListInstall, false); |
| 536 ExpectEventRecorded(kAppListSetToGoogle, false); |
| 537 ExpectEventRecorded(kAppListFirstSearch, false); |
| 538 |
| 473 ExpectRlzPingSent(false); | 539 ExpectRlzPingSent(false); |
| 474 } | 540 } |
| 475 | 541 |
| 476 TEST_F(RlzLibTest, HomepageUsageOnly) { | 542 TEST_F(RlzLibTest, HomepageUsageOnly) { |
| 477 TestRLZTracker::InitRlzDelayed(true, false, kDelay, true, true, false); | 543 TestRLZTracker::InitRlzDelayed(true, false, kDelay, true, true, false); |
| 478 SimulateHomepageUsage(); | 544 SimulateHomepageUsage(); |
| 479 | 545 |
| 480 // Omnibox events. | 546 // Omnibox events. |
| 481 ExpectEventRecorded(kOmniboxInstall, false); | 547 ExpectEventRecorded(kOmniboxInstall, false); |
| 482 ExpectEventRecorded(kOmniboxSetToGoogle, false); | 548 ExpectEventRecorded(kOmniboxSetToGoogle, false); |
| 483 ExpectEventRecorded(kOmniboxFirstSearch, false); | 549 ExpectEventRecorded(kOmniboxFirstSearch, false); |
| 484 | 550 |
| 485 // Home page events. | 551 // Home page events. |
| 486 ExpectEventRecorded(kHomepageInstall, false); | 552 ExpectEventRecorded(kHomepageInstall, false); |
| 487 ExpectEventRecorded(kHomepageSetToGoogle, false); | 553 ExpectEventRecorded(kHomepageSetToGoogle, false); |
| 488 ExpectEventRecorded(kHomepageFirstSeach, true); | 554 ExpectEventRecorded(kHomepageFirstSeach, true); |
| 489 | 555 |
| 556 // App list events. |
| 557 ExpectEventRecorded(kAppListInstall, false); |
| 558 ExpectEventRecorded(kAppListSetToGoogle, false); |
| 559 ExpectEventRecorded(kAppListFirstSearch, false); |
| 560 |
| 490 ExpectRlzPingSent(false); | 561 ExpectRlzPingSent(false); |
| 491 } | 562 } |
| 492 | 563 |
| 564 TEST_F(RlzLibTest, AppListUsageOnly) { |
| 565 TestRLZTracker::InitRlzDelayed(true, false, kDelay, true, true, false); |
| 566 SimulateAppListUsage(); |
| 567 |
| 568 // Omnibox events. |
| 569 ExpectEventRecorded(kOmniboxInstall, false); |
| 570 ExpectEventRecorded(kOmniboxSetToGoogle, false); |
| 571 ExpectEventRecorded(kOmniboxFirstSearch, false); |
| 572 |
| 573 // Home page events. |
| 574 ExpectEventRecorded(kHomepageInstall, false); |
| 575 ExpectEventRecorded(kHomepageSetToGoogle, false); |
| 576 ExpectEventRecorded(kHomepageFirstSeach, false); |
| 577 |
| 578 // App list events. |
| 579 ExpectEventRecorded(kAppListInstall, false); |
| 580 ExpectEventRecorded(kAppListSetToGoogle, false); |
| 581 ExpectEventRecorded(kAppListFirstSearch, true); |
| 582 |
| 583 ExpectRlzPingSent(false); |
| 584 } |
| 585 |
| 493 TEST_F(RlzLibTest, UsageBeforeDelayedInit) { | 586 TEST_F(RlzLibTest, UsageBeforeDelayedInit) { |
| 494 TestRLZTracker::InitRlzDelayed(true, false, kDelay, true, true, false); | 587 TestRLZTracker::InitRlzDelayed(true, false, kDelay, true, true, false); |
| 495 SimulateOmniboxUsage(); | 588 SimulateOmniboxUsage(); |
| 496 SimulateHomepageUsage(); | 589 SimulateHomepageUsage(); |
| 590 SimulateAppListUsage(); |
| 497 InvokeDelayedInit(); | 591 InvokeDelayedInit(); |
| 498 | 592 |
| 499 // Omnibox events. | 593 // Omnibox events. |
| 500 ExpectEventRecorded(kOmniboxInstall, true); | 594 ExpectEventRecorded(kOmniboxInstall, true); |
| 501 ExpectEventRecorded(kOmniboxSetToGoogle, true); | 595 ExpectEventRecorded(kOmniboxSetToGoogle, true); |
| 502 ExpectEventRecorded(kOmniboxFirstSearch, true); | 596 ExpectEventRecorded(kOmniboxFirstSearch, true); |
| 503 | 597 |
| 504 // Home page events. | 598 // Home page events. |
| 505 ExpectEventRecorded(kHomepageInstall, true); | 599 ExpectEventRecorded(kHomepageInstall, true); |
| 506 ExpectEventRecorded(kHomepageSetToGoogle, true); | 600 ExpectEventRecorded(kHomepageSetToGoogle, true); |
| 507 ExpectEventRecorded(kHomepageFirstSeach, true); | 601 ExpectEventRecorded(kHomepageFirstSeach, true); |
| 508 | 602 |
| 603 // App list events. |
| 604 ExpectEventRecorded(kAppListInstall, true); |
| 605 ExpectEventRecorded(kAppListSetToGoogle, true); |
| 606 ExpectEventRecorded(kAppListFirstSearch, true); |
| 607 |
| 509 ExpectRlzPingSent(true); | 608 ExpectRlzPingSent(true); |
| 510 } | 609 } |
| 511 | 610 |
| 512 TEST_F(RlzLibTest, OmniboxUsageAfterDelayedInit) { | 611 TEST_F(RlzLibTest, UsageAfterDelayedInit) { |
| 513 TestRLZTracker::InitRlzDelayed(true, false, kDelay, true, true, false); | 612 TestRLZTracker::InitRlzDelayed(true, false, kDelay, true, true, false); |
| 514 InvokeDelayedInit(); | 613 InvokeDelayedInit(); |
| 515 SimulateOmniboxUsage(); | 614 SimulateOmniboxUsage(); |
| 516 SimulateHomepageUsage(); | 615 SimulateHomepageUsage(); |
| 616 SimulateAppListUsage(); |
| 517 | 617 |
| 518 // Omnibox events. | 618 // Omnibox events. |
| 519 ExpectEventRecorded(kOmniboxInstall, true); | 619 ExpectEventRecorded(kOmniboxInstall, true); |
| 520 ExpectEventRecorded(kOmniboxSetToGoogle, true); | 620 ExpectEventRecorded(kOmniboxSetToGoogle, true); |
| 521 ExpectEventRecorded(kOmniboxFirstSearch, true); | 621 ExpectEventRecorded(kOmniboxFirstSearch, true); |
| 522 | 622 |
| 523 // Home page events. | 623 // Home page events. |
| 524 ExpectEventRecorded(kHomepageInstall, true); | 624 ExpectEventRecorded(kHomepageInstall, true); |
| 525 ExpectEventRecorded(kHomepageSetToGoogle, true); | 625 ExpectEventRecorded(kHomepageSetToGoogle, true); |
| 526 ExpectEventRecorded(kHomepageFirstSeach, true); | 626 ExpectEventRecorded(kHomepageFirstSeach, true); |
| 527 | 627 |
| 628 // App list events. |
| 629 ExpectEventRecorded(kAppListInstall, true); |
| 630 ExpectEventRecorded(kAppListSetToGoogle, true); |
| 631 ExpectEventRecorded(kAppListFirstSearch, true); |
| 632 |
| 528 ExpectRlzPingSent(true); | 633 ExpectRlzPingSent(true); |
| 529 } | 634 } |
| 530 | 635 |
| 531 TEST_F(RlzLibTest, OmniboxUsageSendsPingWhenSendPingImmediately) { | 636 TEST_F(RlzLibTest, OmniboxUsageSendsPingWhenSendPingImmediately) { |
| 532 TestRLZTracker::InitRlzDelayed(true, true, kDelay, true, true, false); | 637 TestRLZTracker::InitRlzDelayed(true, true, kDelay, true, true, false); |
| 533 SimulateOmniboxUsage(); | 638 SimulateOmniboxUsage(); |
| 534 | 639 |
| 535 // Omnibox events. | 640 // Omnibox events. |
| 536 ExpectEventRecorded(kOmniboxInstall, true); | 641 ExpectEventRecorded(kOmniboxInstall, true); |
| 537 ExpectEventRecorded(kOmniboxSetToGoogle, true); | 642 ExpectEventRecorded(kOmniboxSetToGoogle, true); |
| 538 ExpectEventRecorded(kOmniboxFirstSearch, true); | 643 ExpectEventRecorded(kOmniboxFirstSearch, true); |
| 539 | 644 |
| 540 // Home page events. | 645 // Home page events. |
| 541 ExpectEventRecorded(kHomepageInstall, true); | 646 ExpectEventRecorded(kHomepageInstall, true); |
| 542 ExpectEventRecorded(kHomepageSetToGoogle, true); | 647 ExpectEventRecorded(kHomepageSetToGoogle, true); |
| 543 ExpectEventRecorded(kHomepageFirstSeach, false); | 648 ExpectEventRecorded(kHomepageFirstSeach, false); |
| 544 | 649 |
| 650 // App list events. |
| 651 ExpectEventRecorded(kAppListInstall, true); |
| 652 ExpectEventRecorded(kAppListSetToGoogle, true); |
| 653 ExpectEventRecorded(kAppListFirstSearch, false); |
| 654 |
| 545 ExpectRlzPingSent(true); | 655 ExpectRlzPingSent(true); |
| 546 } | 656 } |
| 547 | 657 |
| 548 TEST_F(RlzLibTest, HomepageUsageDoesNotSendPingWhenSendPingImmediately) { | 658 TEST_F(RlzLibTest, HomepageUsageDoesNotSendPingWhenSendPingImmediately) { |
| 549 TestRLZTracker::InitRlzDelayed(true, true, kDelay, true, true, false); | 659 TestRLZTracker::InitRlzDelayed(true, true, kDelay, true, true, false); |
| 550 SimulateHomepageUsage(); | 660 SimulateHomepageUsage(); |
| 551 | 661 |
| 552 // Omnibox events. | 662 // Omnibox events. |
| 553 ExpectEventRecorded(kOmniboxInstall, false); | 663 ExpectEventRecorded(kOmniboxInstall, false); |
| 554 ExpectEventRecorded(kOmniboxSetToGoogle, false); | 664 ExpectEventRecorded(kOmniboxSetToGoogle, false); |
| 555 ExpectEventRecorded(kOmniboxFirstSearch, false); | 665 ExpectEventRecorded(kOmniboxFirstSearch, false); |
| 556 | 666 |
| 557 // Home page events. | 667 // Home page events. |
| 558 ExpectEventRecorded(kHomepageInstall, false); | 668 ExpectEventRecorded(kHomepageInstall, false); |
| 559 ExpectEventRecorded(kHomepageSetToGoogle, false); | 669 ExpectEventRecorded(kHomepageSetToGoogle, false); |
| 560 ExpectEventRecorded(kHomepageFirstSeach, true); | 670 ExpectEventRecorded(kHomepageFirstSeach, true); |
| 561 | 671 |
| 672 // App list events. |
| 673 ExpectEventRecorded(kAppListInstall, false); |
| 674 ExpectEventRecorded(kAppListSetToGoogle, false); |
| 675 ExpectEventRecorded(kAppListFirstSearch, false); |
| 676 |
| 562 ExpectRlzPingSent(false); | 677 ExpectRlzPingSent(false); |
| 563 } | 678 } |
| 564 | 679 |
| 565 TEST_F(RlzLibTest, StartupUsageDoesNotSendPingWhenSendPingImmediately) { | 680 TEST_F(RlzLibTest, StartupUsageDoesNotSendPingWhenSendPingImmediately) { |
| 566 TestRLZTracker::InitRlzDelayed(true, true, kDelay, true, false, true); | 681 TestRLZTracker::InitRlzDelayed(true, true, kDelay, true, false, true); |
| 567 SimulateHomepageUsage(); | 682 SimulateHomepageUsage(); |
| 568 | 683 |
| 569 // Omnibox events. | 684 // Omnibox events. |
| 570 ExpectEventRecorded(kOmniboxInstall, false); | 685 ExpectEventRecorded(kOmniboxInstall, false); |
| 571 ExpectEventRecorded(kOmniboxSetToGoogle, false); | 686 ExpectEventRecorded(kOmniboxSetToGoogle, false); |
| 572 ExpectEventRecorded(kOmniboxFirstSearch, false); | 687 ExpectEventRecorded(kOmniboxFirstSearch, false); |
| 573 | 688 |
| 574 // Home page events. | 689 // Home page events. |
| 575 ExpectEventRecorded(kHomepageInstall, false); | 690 ExpectEventRecorded(kHomepageInstall, false); |
| 576 ExpectEventRecorded(kHomepageSetToGoogle, false); | 691 ExpectEventRecorded(kHomepageSetToGoogle, false); |
| 577 ExpectEventRecorded(kHomepageFirstSeach, true); | 692 ExpectEventRecorded(kHomepageFirstSeach, true); |
| 578 | 693 |
| 694 // App list events. |
| 695 ExpectEventRecorded(kAppListInstall, false); |
| 696 ExpectEventRecorded(kAppListSetToGoogle, false); |
| 697 ExpectEventRecorded(kAppListFirstSearch, false); |
| 698 |
| 579 ExpectRlzPingSent(false); | 699 ExpectRlzPingSent(false); |
| 580 } | 700 } |
| 581 | 701 |
| 702 TEST_F(RlzLibTest, AppListUsageDoesNotSendPingWhenSendPingImmediately) { |
| 703 TestRLZTracker::InitRlzDelayed(true, true, kDelay, true, false, false); |
| 704 SimulateAppListUsage(); |
| 705 |
| 706 // Omnibox events. |
| 707 ExpectEventRecorded(kOmniboxInstall, false); |
| 708 ExpectEventRecorded(kOmniboxSetToGoogle, false); |
| 709 ExpectEventRecorded(kOmniboxFirstSearch, false); |
| 710 |
| 711 // Home page events. |
| 712 ExpectEventRecorded(kHomepageInstall, false); |
| 713 ExpectEventRecorded(kHomepageSetToGoogle, false); |
| 714 ExpectEventRecorded(kHomepageFirstSeach, false); |
| 715 |
| 716 // App list events. |
| 717 ExpectEventRecorded(kAppListInstall, false); |
| 718 ExpectEventRecorded(kAppListSetToGoogle, false); |
| 719 ExpectEventRecorded(kAppListFirstSearch, true); |
| 720 |
| 721 ExpectRlzPingSent(false); |
| 722 } |
| 723 |
| 582 TEST_F(RlzLibTest, GetAccessPointRlzOnIoThread) { | 724 TEST_F(RlzLibTest, GetAccessPointRlzOnIoThread) { |
| 583 // Set dummy RLZ string. | 725 // Set dummy RLZ string. |
| 584 rlz_lib::SetAccessPointRlz(RLZTracker::CHROME_OMNIBOX, kOmniboxRlzString); | 726 rlz_lib::SetAccessPointRlz(RLZTracker::CHROME_OMNIBOX, kOmniboxRlzString); |
| 585 | 727 |
| 586 base::string16 rlz; | 728 base::string16 rlz; |
| 587 | 729 |
| 588 tracker_.set_assume_not_ui_thread(true); | 730 tracker_.set_assume_not_ui_thread(true); |
| 589 EXPECT_TRUE(RLZTracker::GetAccessPointRlz(RLZTracker::CHROME_OMNIBOX, &rlz)); | 731 EXPECT_TRUE(RLZTracker::GetAccessPointRlz(RLZTracker::CHROME_OMNIBOX, &rlz)); |
| 590 EXPECT_STREQ(kOmniboxRlzString, base::UTF16ToUTF8(rlz).c_str()); | 732 EXPECT_STREQ(kOmniboxRlzString, base::UTF16ToUTF8(rlz).c_str()); |
| 591 } | 733 } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 615 | 757 |
| 616 tracker_.set_assume_not_ui_thread(false); | 758 tracker_.set_assume_not_ui_thread(false); |
| 617 EXPECT_TRUE(RLZTracker::GetAccessPointRlz(RLZTracker::CHROME_OMNIBOX, &rlz)); | 759 EXPECT_TRUE(RLZTracker::GetAccessPointRlz(RLZTracker::CHROME_OMNIBOX, &rlz)); |
| 618 EXPECT_STREQ(kOmniboxRlzString, base::UTF16ToUTF8(rlz).c_str()); | 760 EXPECT_STREQ(kOmniboxRlzString, base::UTF16ToUTF8(rlz).c_str()); |
| 619 } | 761 } |
| 620 | 762 |
| 621 TEST_F(RlzLibTest, PingUpdatesRlzCache) { | 763 TEST_F(RlzLibTest, PingUpdatesRlzCache) { |
| 622 // Set dummy RLZ string. | 764 // Set dummy RLZ string. |
| 623 rlz_lib::SetAccessPointRlz(RLZTracker::CHROME_OMNIBOX, kOmniboxRlzString); | 765 rlz_lib::SetAccessPointRlz(RLZTracker::CHROME_OMNIBOX, kOmniboxRlzString); |
| 624 rlz_lib::SetAccessPointRlz(RLZTracker::CHROME_HOME_PAGE, kHomepageRlzString); | 766 rlz_lib::SetAccessPointRlz(RLZTracker::CHROME_HOME_PAGE, kHomepageRlzString); |
| 767 rlz_lib::SetAccessPointRlz(RLZTracker::CHROME_APP_LIST, kAppListRlzString); |
| 625 | 768 |
| 626 base::string16 rlz; | 769 base::string16 rlz; |
| 627 | 770 |
| 628 // Prime the cache. | 771 // Prime the cache. |
| 629 tracker_.set_assume_not_ui_thread(true); | 772 tracker_.set_assume_not_ui_thread(true); |
| 630 | 773 |
| 631 EXPECT_TRUE(RLZTracker::GetAccessPointRlz(RLZTracker::CHROME_OMNIBOX, &rlz)); | 774 EXPECT_TRUE(RLZTracker::GetAccessPointRlz(RLZTracker::CHROME_OMNIBOX, &rlz)); |
| 632 EXPECT_STREQ(kOmniboxRlzString, base::UTF16ToUTF8(rlz).c_str()); | 775 EXPECT_STREQ(kOmniboxRlzString, base::UTF16ToUTF8(rlz).c_str()); |
| 633 EXPECT_TRUE(RLZTracker::GetAccessPointRlz( | 776 EXPECT_TRUE(RLZTracker::GetAccessPointRlz( |
| 634 RLZTracker::CHROME_HOME_PAGE, &rlz)); | 777 RLZTracker::CHROME_HOME_PAGE, &rlz)); |
| 635 EXPECT_STREQ(kHomepageRlzString, base::UTF16ToUTF8(rlz).c_str()); | 778 EXPECT_STREQ(kHomepageRlzString, base::UTF16ToUTF8(rlz).c_str()); |
| 779 EXPECT_TRUE(RLZTracker::GetAccessPointRlz(RLZTracker::CHROME_APP_LIST, &rlz)); |
| 780 EXPECT_STREQ(kAppListRlzString, base::UTF16ToUTF8(rlz).c_str()); |
| 636 | 781 |
| 637 // Make sure cache is valid. | 782 // Make sure cache is valid. |
| 638 tracker_.set_assume_not_ui_thread(false); | 783 tracker_.set_assume_not_ui_thread(false); |
| 639 | 784 |
| 640 EXPECT_TRUE(RLZTracker::GetAccessPointRlz(RLZTracker::CHROME_OMNIBOX, &rlz)); | 785 EXPECT_TRUE(RLZTracker::GetAccessPointRlz(RLZTracker::CHROME_OMNIBOX, &rlz)); |
| 641 EXPECT_STREQ(kOmniboxRlzString, base::UTF16ToUTF8(rlz).c_str()); | 786 EXPECT_STREQ(kOmniboxRlzString, base::UTF16ToUTF8(rlz).c_str()); |
| 642 EXPECT_TRUE(RLZTracker::GetAccessPointRlz( | 787 EXPECT_TRUE(RLZTracker::GetAccessPointRlz( |
| 643 RLZTracker::CHROME_HOME_PAGE, &rlz)); | 788 RLZTracker::CHROME_HOME_PAGE, &rlz)); |
| 644 EXPECT_STREQ(kHomepageRlzString, base::UTF16ToUTF8(rlz).c_str()); | 789 EXPECT_STREQ(kHomepageRlzString, base::UTF16ToUTF8(rlz).c_str()); |
| 790 EXPECT_TRUE(RLZTracker::GetAccessPointRlz(RLZTracker::CHROME_APP_LIST, &rlz)); |
| 791 EXPECT_STREQ(kAppListRlzString, base::UTF16ToUTF8(rlz).c_str()); |
| 645 | 792 |
| 646 // Perform ping. | 793 // Perform ping. |
| 647 tracker_.set_assume_not_ui_thread(true); | 794 tracker_.set_assume_not_ui_thread(true); |
| 648 TestRLZTracker::InitRlzDelayed(true, false, kDelay, true, true, false); | 795 TestRLZTracker::InitRlzDelayed(true, false, kDelay, true, true, false); |
| 649 InvokeDelayedInit(); | 796 InvokeDelayedInit(); |
| 650 ExpectRlzPingSent(true); | 797 ExpectRlzPingSent(true); |
| 651 | 798 |
| 652 // Make sure cache is now updated. | 799 // Make sure cache is now updated. |
| 653 tracker_.set_assume_not_ui_thread(false); | 800 tracker_.set_assume_not_ui_thread(false); |
| 654 | 801 |
| 655 EXPECT_TRUE(RLZTracker::GetAccessPointRlz(RLZTracker::CHROME_OMNIBOX, &rlz)); | 802 EXPECT_TRUE(RLZTracker::GetAccessPointRlz(RLZTracker::CHROME_OMNIBOX, &rlz)); |
| 656 EXPECT_STREQ(kNewOmniboxRlzString, base::UTF16ToUTF8(rlz).c_str()); | 803 EXPECT_STREQ(kNewOmniboxRlzString, base::UTF16ToUTF8(rlz).c_str()); |
| 657 EXPECT_TRUE(RLZTracker::GetAccessPointRlz( | 804 EXPECT_TRUE(RLZTracker::GetAccessPointRlz( |
| 658 RLZTracker::CHROME_HOME_PAGE, &rlz)); | 805 RLZTracker::CHROME_HOME_PAGE, &rlz)); |
| 659 EXPECT_STREQ(kNewHomepageRlzString, base::UTF16ToUTF8(rlz).c_str()); | 806 EXPECT_STREQ(kNewHomepageRlzString, base::UTF16ToUTF8(rlz).c_str()); |
| 807 EXPECT_TRUE(RLZTracker::GetAccessPointRlz(RLZTracker::CHROME_APP_LIST, &rlz)); |
| 808 EXPECT_STREQ(kNewAppListRlzString, base::UTF16ToUTF8(rlz).c_str()); |
| 660 } | 809 } |
| 661 | 810 |
| 662 TEST_F(RlzLibTest, ObserveHandlesBadArgs) { | 811 TEST_F(RlzLibTest, ObserveHandlesBadArgs) { |
| 663 scoped_ptr<NavigationEntry> entry(NavigationEntry::Create()); | 812 scoped_ptr<NavigationEntry> entry(NavigationEntry::Create()); |
| 664 entry->SetPageID(0); | 813 entry->SetPageID(0); |
| 665 entry->SetTransitionType(content::PAGE_TRANSITION_LINK); | 814 entry->SetTransitionType(content::PAGE_TRANSITION_LINK); |
| 666 tracker_.Observe(content::NOTIFICATION_NAV_ENTRY_PENDING, | 815 tracker_.Observe(content::NOTIFICATION_NAV_ENTRY_PENDING, |
| 667 content::NotificationService::AllSources(), | 816 content::NotificationService::AllSources(), |
| 668 content::Details<NavigationEntry>(NULL)); | 817 content::Details<NavigationEntry>(NULL)); |
| 669 tracker_.Observe(content::NOTIFICATION_NAV_ENTRY_PENDING, | 818 tracker_.Observe(content::NOTIFICATION_NAV_ENTRY_PENDING, |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 722 RLZTracker::RecordProductEvent(rlz_lib::CHROME, RLZTracker::CHROME_OMNIBOX, | 871 RLZTracker::RecordProductEvent(rlz_lib::CHROME, RLZTracker::CHROME_OMNIBOX, |
| 723 rlz_lib::FIRST_SEARCH); | 872 rlz_lib::FIRST_SEARCH); |
| 724 | 873 |
| 725 ExpectEventRecorded(kOmniboxFirstSearch, true); | 874 ExpectEventRecorded(kOmniboxFirstSearch, true); |
| 726 | 875 |
| 727 RLZTracker::ClearRlzState(); | 876 RLZTracker::ClearRlzState(); |
| 728 | 877 |
| 729 ExpectEventRecorded(kOmniboxFirstSearch, false); | 878 ExpectEventRecorded(kOmniboxFirstSearch, false); |
| 730 } | 879 } |
| 731 #endif // defined(OS_CHROMEOS) | 880 #endif // defined(OS_CHROMEOS) |
| OLD | NEW |