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 { |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
266 } | 270 } |
267 | 271 |
268 // The events that affect the different RLZ scenarios are the following: | 272 // The events that affect the different RLZ scenarios are the following: |
269 // | 273 // |
270 // A: the user starts chrome for the first time | 274 // A: the user starts chrome for the first time |
271 // B: the user stops chrome | 275 // B: the user stops chrome |
272 // C: the user start a subsequent time | 276 // C: the user start a subsequent time |
273 // D: the user stops chrome again | 277 // D: the user stops chrome again |
274 // I: the RLZTracker::DelayedInit() method is invoked | 278 // I: the RLZTracker::DelayedInit() method is invoked |
275 // X: the user performs a search using the omnibox | 279 // X: the user performs a search using the omnibox |
276 // Y: the user performs a search using the home page | 280 // Y: the user performs a search using the home page |
Roger Tawa OOO till Jul 10th
2014/04/01 14:20:18
I think we need a comment like:
Z: the user perfo
Sam McNally
2014/04/02 01:27:28
Done.
| |
277 // | 281 // |
278 // The events A to D happen in chronological order, but the other events | 282 // 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. | 283 // may happen at any point between A-B or C-D, in no particular order. |
280 // | 284 // |
281 // The visible results of the scenarios on Win are: | 285 // The visible results of the scenarios on Win are: |
282 // | 286 // |
283 // C1I event is recorded | 287 // C1I event is recorded |
284 // C2I event is recorded | 288 // C2I event is recorded |
285 // C1F event is recorded | 289 // C1F event is recorded |
286 // C2F event is recorded | 290 // C2F event is recorded |
(...skipping 12 matching lines...) Expand all Loading... | |
299 // Also want to test that pre-warming the RLZ string cache works correctly. | 303 // Also want to test that pre-warming the RLZ string cache works correctly. |
300 | 304 |
301 #if defined(OS_WIN) | 305 #if defined(OS_WIN) |
302 const char kOmniboxInstall[] = "C1I"; | 306 const char kOmniboxInstall[] = "C1I"; |
303 const char kOmniboxSetToGoogle[] = "C1S"; | 307 const char kOmniboxSetToGoogle[] = "C1S"; |
304 const char kOmniboxFirstSearch[] = "C1F"; | 308 const char kOmniboxFirstSearch[] = "C1F"; |
305 | 309 |
306 const char kHomepageInstall[] = "C2I"; | 310 const char kHomepageInstall[] = "C2I"; |
307 const char kHomepageSetToGoogle[] = "C2S"; | 311 const char kHomepageSetToGoogle[] = "C2S"; |
308 const char kHomepageFirstSeach[] = "C2F"; | 312 const char kHomepageFirstSeach[] = "C2F"; |
313 | |
314 const char kApplistInstall[] = "C7I"; | |
315 const char kApplistSetToGoogle[] = "C7S"; | |
316 const char kApplistFirstSearch[] = "C7F"; | |
309 #elif defined(OS_MACOSX) | 317 #elif defined(OS_MACOSX) |
310 const char kOmniboxInstall[] = "C5I"; | 318 const char kOmniboxInstall[] = "C5I"; |
311 const char kOmniboxSetToGoogle[] = "C5S"; | 319 const char kOmniboxSetToGoogle[] = "C5S"; |
312 const char kOmniboxFirstSearch[] = "C5F"; | 320 const char kOmniboxFirstSearch[] = "C5F"; |
313 | 321 |
314 const char kHomepageInstall[] = "C6I"; | 322 const char kHomepageInstall[] = "C6I"; |
315 const char kHomepageSetToGoogle[] = "C6S"; | 323 const char kHomepageSetToGoogle[] = "C6S"; |
316 const char kHomepageFirstSeach[] = "C6F"; | 324 const char kHomepageFirstSeach[] = "C6F"; |
325 | |
326 const char kApplistInstall[] = "C8I"; | |
327 const char kApplistSetToGoogle[] = "C8S"; | |
328 const char kApplistFirstSearch[] = "C8F"; | |
317 #elif defined(OS_CHROMEOS) | 329 #elif defined(OS_CHROMEOS) |
318 const char kOmniboxInstall[] = "CAI"; | 330 const char kOmniboxInstall[] = "CAI"; |
319 const char kOmniboxSetToGoogle[] = "CAS"; | 331 const char kOmniboxSetToGoogle[] = "CAS"; |
320 const char kOmniboxFirstSearch[] = "CAF"; | 332 const char kOmniboxFirstSearch[] = "CAF"; |
321 | 333 |
322 const char kHomepageInstall[] = "CBI"; | 334 const char kHomepageInstall[] = "CBI"; |
323 const char kHomepageSetToGoogle[] = "CBS"; | 335 const char kHomepageSetToGoogle[] = "CBS"; |
324 const char kHomepageFirstSeach[] = "CBF"; | 336 const char kHomepageFirstSeach[] = "CBF"; |
337 | |
338 const char kApplistInstall[] = "CCI"; | |
339 const char kApplistSetToGoogle[] = "CCS"; | |
340 const char kApplistFirstSearch[] = "CCF"; | |
325 #endif | 341 #endif |
Roger Tawa OOO till Jul 10th
2014/04/01 14:20:18
I think we need tests specific to iOS. This is im
Sam McNally
2014/04/02 01:27:28
Changed to use #ifdefs for iOS instead.
| |
326 | 342 |
327 const base::TimeDelta kDelay = base::TimeDelta::FromMilliseconds(20); | 343 const base::TimeDelta kDelay = base::TimeDelta::FromMilliseconds(20); |
328 | 344 |
329 TEST_F(RlzLibTest, RecordProductEvent) { | 345 TEST_F(RlzLibTest, RecordProductEvent) { |
330 RLZTracker::RecordProductEvent(rlz_lib::CHROME, RLZTracker::CHROME_OMNIBOX, | 346 RLZTracker::RecordProductEvent(rlz_lib::CHROME, RLZTracker::CHROME_OMNIBOX, |
331 rlz_lib::FIRST_SEARCH); | 347 rlz_lib::FIRST_SEARCH); |
332 | 348 |
333 ExpectEventRecorded(kOmniboxFirstSearch, true); | 349 ExpectEventRecorded(kOmniboxFirstSearch, true); |
334 } | 350 } |
335 | 351 |
336 TEST_F(RlzLibTest, QuickStopAfterStart) { | 352 TEST_F(RlzLibTest, QuickStopAfterStart) { |
337 TestRLZTracker::InitRlzDelayed(true, false, kDelay, true, true, true); | 353 TestRLZTracker::InitRlzDelayed(true, false, kDelay, true, true, true); |
338 | 354 |
339 // Omnibox events. | 355 // Omnibox events. |
340 ExpectEventRecorded(kOmniboxInstall, false); | 356 ExpectEventRecorded(kOmniboxInstall, false); |
341 ExpectEventRecorded(kOmniboxSetToGoogle, false); | 357 ExpectEventRecorded(kOmniboxSetToGoogle, false); |
342 ExpectEventRecorded(kOmniboxFirstSearch, false); | 358 ExpectEventRecorded(kOmniboxFirstSearch, false); |
343 | 359 |
344 // Home page events. | 360 // Home page events. |
345 ExpectEventRecorded(kHomepageInstall, false); | 361 ExpectEventRecorded(kHomepageInstall, false); |
346 ExpectEventRecorded(kHomepageSetToGoogle, false); | 362 ExpectEventRecorded(kHomepageSetToGoogle, false); |
347 ExpectEventRecorded(kHomepageFirstSeach, false); | 363 ExpectEventRecorded(kHomepageFirstSeach, false); |
348 | 364 |
365 // App list events. | |
366 ExpectEventRecorded(kApplistInstall, false); | |
367 ExpectEventRecorded(kApplistSetToGoogle, false); | |
368 ExpectEventRecorded(kApplistFirstSearch, false); | |
369 | |
349 ExpectRlzPingSent(false); | 370 ExpectRlzPingSent(false); |
350 } | 371 } |
351 | 372 |
352 TEST_F(RlzLibTest, DelayedInitOnly) { | 373 TEST_F(RlzLibTest, DelayedInitOnly) { |
353 TestRLZTracker::InitRlzDelayed(true, false, kDelay, true, true, false); | 374 TestRLZTracker::InitRlzDelayed(true, false, kDelay, true, true, false); |
354 InvokeDelayedInit(); | 375 InvokeDelayedInit(); |
355 | 376 |
356 // Omnibox events. | 377 // Omnibox events. |
357 ExpectEventRecorded(kOmniboxInstall, true); | 378 ExpectEventRecorded(kOmniboxInstall, true); |
358 ExpectEventRecorded(kOmniboxSetToGoogle, true); | 379 ExpectEventRecorded(kOmniboxSetToGoogle, true); |
359 ExpectEventRecorded(kOmniboxFirstSearch, false); | 380 ExpectEventRecorded(kOmniboxFirstSearch, false); |
360 | 381 |
361 // Home page events. | 382 // Home page events. |
362 ExpectEventRecorded(kHomepageInstall, true); | 383 ExpectEventRecorded(kHomepageInstall, true); |
363 ExpectEventRecorded(kHomepageSetToGoogle, true); | 384 ExpectEventRecorded(kHomepageSetToGoogle, true); |
364 ExpectEventRecorded(kHomepageFirstSeach, false); | 385 ExpectEventRecorded(kHomepageFirstSeach, false); |
365 | 386 |
387 // App list events. | |
388 ExpectEventRecorded(kApplistInstall, true); | |
389 ExpectEventRecorded(kApplistSetToGoogle, true); | |
390 ExpectEventRecorded(kApplistFirstSearch, false); | |
391 | |
366 ExpectRlzPingSent(true); | 392 ExpectRlzPingSent(true); |
367 } | 393 } |
368 | 394 |
369 TEST_F(RlzLibTest, DelayedInitOnlyGoogleAsStartup) { | 395 TEST_F(RlzLibTest, DelayedInitOnlyGoogleAsStartup) { |
370 TestRLZTracker::InitRlzDelayed(true, false, kDelay, false, false, true); | 396 TestRLZTracker::InitRlzDelayed(true, false, kDelay, false, false, true); |
371 InvokeDelayedInit(); | 397 InvokeDelayedInit(); |
372 | 398 |
373 // Omnibox events. | 399 // Omnibox events. |
374 ExpectEventRecorded(kOmniboxInstall, true); | 400 ExpectEventRecorded(kOmniboxInstall, true); |
375 ExpectEventRecorded(kOmniboxSetToGoogle, false); | 401 ExpectEventRecorded(kOmniboxSetToGoogle, false); |
376 ExpectEventRecorded(kOmniboxFirstSearch, false); | 402 ExpectEventRecorded(kOmniboxFirstSearch, false); |
377 | 403 |
378 // Home page events. | 404 // Home page events. |
379 ExpectEventRecorded(kHomepageInstall, true); | 405 ExpectEventRecorded(kHomepageInstall, true); |
380 ExpectEventRecorded(kHomepageSetToGoogle, true); | 406 ExpectEventRecorded(kHomepageSetToGoogle, true); |
381 ExpectEventRecorded(kHomepageFirstSeach, true); | 407 ExpectEventRecorded(kHomepageFirstSeach, true); |
382 | 408 |
409 // App list events. | |
410 ExpectEventRecorded(kApplistInstall, true); | |
411 ExpectEventRecorded(kApplistSetToGoogle, false); | |
412 ExpectEventRecorded(kApplistFirstSearch, false); | |
413 | |
383 ExpectRlzPingSent(true); | 414 ExpectRlzPingSent(true); |
384 } | 415 } |
385 | 416 |
386 TEST_F(RlzLibTest, DelayedInitOnlyNoFirstRunNoRlzStrings) { | 417 TEST_F(RlzLibTest, DelayedInitOnlyNoFirstRunNoRlzStrings) { |
387 TestRLZTracker::InitRlzDelayed(false, false, kDelay, true, true, false); | 418 TestRLZTracker::InitRlzDelayed(false, false, kDelay, true, true, false); |
388 InvokeDelayedInit(); | 419 InvokeDelayedInit(); |
389 | 420 |
390 // Omnibox events. | 421 // Omnibox events. |
391 ExpectEventRecorded(kOmniboxInstall, true); | 422 ExpectEventRecorded(kOmniboxInstall, true); |
392 ExpectEventRecorded(kOmniboxSetToGoogle, true); | 423 ExpectEventRecorded(kOmniboxSetToGoogle, true); |
393 ExpectEventRecorded(kOmniboxFirstSearch, false); | 424 ExpectEventRecorded(kOmniboxFirstSearch, false); |
394 | 425 |
395 // Home page events. | 426 // Home page events. |
396 ExpectEventRecorded(kHomepageInstall, true); | 427 ExpectEventRecorded(kHomepageInstall, true); |
397 ExpectEventRecorded(kHomepageSetToGoogle, true); | 428 ExpectEventRecorded(kHomepageSetToGoogle, true); |
398 ExpectEventRecorded(kHomepageFirstSeach, false); | 429 ExpectEventRecorded(kHomepageFirstSeach, false); |
399 | 430 |
431 // App list events. | |
432 ExpectEventRecorded(kApplistInstall, true); | |
433 ExpectEventRecorded(kApplistSetToGoogle, true); | |
434 ExpectEventRecorded(kApplistFirstSearch, false); | |
435 | |
400 ExpectRlzPingSent(true); | 436 ExpectRlzPingSent(true); |
401 } | 437 } |
402 | 438 |
403 TEST_F(RlzLibTest, DelayedInitOnlyNoFirstRunNoRlzStringsGoogleAsStartup) { | 439 TEST_F(RlzLibTest, DelayedInitOnlyNoFirstRunNoRlzStringsGoogleAsStartup) { |
404 TestRLZTracker::InitRlzDelayed(false, false, kDelay, false, false, true); | 440 TestRLZTracker::InitRlzDelayed(false, false, kDelay, false, false, true); |
405 InvokeDelayedInit(); | 441 InvokeDelayedInit(); |
406 | 442 |
407 // Omnibox events. | 443 // Omnibox events. |
408 ExpectEventRecorded(kOmniboxInstall, true); | 444 ExpectEventRecorded(kOmniboxInstall, true); |
409 ExpectEventRecorded(kOmniboxSetToGoogle, false); | 445 ExpectEventRecorded(kOmniboxSetToGoogle, false); |
410 ExpectEventRecorded(kOmniboxFirstSearch, false); | 446 ExpectEventRecorded(kOmniboxFirstSearch, false); |
411 | 447 |
412 // Home page events. | 448 // Home page events. |
413 ExpectEventRecorded(kHomepageInstall, true); | 449 ExpectEventRecorded(kHomepageInstall, true); |
414 ExpectEventRecorded(kHomepageSetToGoogle, true); | 450 ExpectEventRecorded(kHomepageSetToGoogle, true); |
415 ExpectEventRecorded(kHomepageFirstSeach, true); | 451 ExpectEventRecorded(kHomepageFirstSeach, true); |
416 | 452 |
453 // App list events. | |
454 ExpectEventRecorded(kApplistInstall, true); | |
455 ExpectEventRecorded(kApplistSetToGoogle, false); | |
456 ExpectEventRecorded(kApplistFirstSearch, false); | |
457 | |
417 ExpectRlzPingSent(true); | 458 ExpectRlzPingSent(true); |
418 } | 459 } |
419 | 460 |
420 TEST_F(RlzLibTest, DelayedInitOnlyNoFirstRun) { | 461 TEST_F(RlzLibTest, DelayedInitOnlyNoFirstRun) { |
421 // Set some dummy RLZ strings to simulate that we already ran before and | 462 // Set some dummy RLZ strings to simulate that we already ran before and |
422 // performed a successful ping to the RLZ server. | 463 // performed a successful ping to the RLZ server. |
423 rlz_lib::SetAccessPointRlz(RLZTracker::CHROME_OMNIBOX, kOmniboxRlzString); | 464 rlz_lib::SetAccessPointRlz(RLZTracker::CHROME_OMNIBOX, kOmniboxRlzString); |
424 rlz_lib::SetAccessPointRlz(RLZTracker::CHROME_HOME_PAGE, kHomepageRlzString); | 465 rlz_lib::SetAccessPointRlz(RLZTracker::CHROME_HOME_PAGE, kHomepageRlzString); |
466 rlz_lib::SetAccessPointRlz(RLZTracker::CHROME_APP_LIST, kApplistRlzString); | |
425 | 467 |
426 TestRLZTracker::InitRlzDelayed(false, false, kDelay, true, true, true); | 468 TestRLZTracker::InitRlzDelayed(false, false, kDelay, true, true, true); |
427 InvokeDelayedInit(); | 469 InvokeDelayedInit(); |
428 | 470 |
429 // Omnibox events. | 471 // Omnibox events. |
430 ExpectEventRecorded(kOmniboxInstall, true); | 472 ExpectEventRecorded(kOmniboxInstall, true); |
431 ExpectEventRecorded(kOmniboxSetToGoogle, false); | 473 ExpectEventRecorded(kOmniboxSetToGoogle, false); |
432 ExpectEventRecorded(kOmniboxFirstSearch, false); | 474 ExpectEventRecorded(kOmniboxFirstSearch, false); |
433 | 475 |
434 // Home page events. | 476 // Home page events. |
435 ExpectEventRecorded(kHomepageInstall, true); | 477 ExpectEventRecorded(kHomepageInstall, true); |
436 ExpectEventRecorded(kHomepageSetToGoogle, false); | 478 ExpectEventRecorded(kHomepageSetToGoogle, false); |
437 ExpectEventRecorded(kHomepageFirstSeach, true); | 479 ExpectEventRecorded(kHomepageFirstSeach, true); |
438 | 480 |
481 // App list events. | |
482 ExpectEventRecorded(kApplistInstall, true); | |
483 ExpectEventRecorded(kApplistSetToGoogle, false); | |
484 ExpectEventRecorded(kApplistFirstSearch, false); | |
485 | |
439 ExpectRlzPingSent(true); | 486 ExpectRlzPingSent(true); |
440 } | 487 } |
441 | 488 |
442 TEST_F(RlzLibTest, DelayedInitOnlyNoGoogleDefaultSearchOrHomepageOrStartup) { | 489 TEST_F(RlzLibTest, DelayedInitOnlyNoGoogleDefaultSearchOrHomepageOrStartup) { |
443 TestRLZTracker::InitRlzDelayed(true, false, kDelay, false, false, false); | 490 TestRLZTracker::InitRlzDelayed(true, false, kDelay, false, false, false); |
444 InvokeDelayedInit(); | 491 InvokeDelayedInit(); |
445 | 492 |
446 // Omnibox events. | 493 // Omnibox events. |
447 ExpectEventRecorded(kOmniboxInstall, true); | 494 ExpectEventRecorded(kOmniboxInstall, true); |
448 ExpectEventRecorded(kOmniboxSetToGoogle, false); | 495 ExpectEventRecorded(kOmniboxSetToGoogle, false); |
449 ExpectEventRecorded(kOmniboxFirstSearch, false); | 496 ExpectEventRecorded(kOmniboxFirstSearch, false); |
450 | 497 |
451 // Home page events. | 498 // Home page events. |
452 ExpectEventRecorded(kHomepageInstall, true); | 499 ExpectEventRecorded(kHomepageInstall, true); |
453 ExpectEventRecorded(kHomepageSetToGoogle, false); | 500 ExpectEventRecorded(kHomepageSetToGoogle, false); |
454 ExpectEventRecorded(kHomepageFirstSeach, false); | 501 ExpectEventRecorded(kHomepageFirstSeach, false); |
455 | 502 |
503 // App list events. | |
504 ExpectEventRecorded(kApplistInstall, true); | |
505 ExpectEventRecorded(kApplistSetToGoogle, false); | |
506 ExpectEventRecorded(kApplistFirstSearch, false); | |
507 | |
456 ExpectRlzPingSent(true); | 508 ExpectRlzPingSent(true); |
457 } | 509 } |
458 | 510 |
459 TEST_F(RlzLibTest, OmniboxUsageOnly) { | 511 TEST_F(RlzLibTest, OmniboxUsageOnly) { |
460 TestRLZTracker::InitRlzDelayed(true, false, kDelay, true, true, false); | 512 TestRLZTracker::InitRlzDelayed(true, false, kDelay, true, true, false); |
461 SimulateOmniboxUsage(); | 513 SimulateOmniboxUsage(); |
462 | 514 |
463 // Omnibox events. | 515 // Omnibox events. |
464 ExpectEventRecorded(kOmniboxInstall, false); | 516 ExpectEventRecorded(kOmniboxInstall, false); |
465 ExpectEventRecorded(kOmniboxSetToGoogle, false); | 517 ExpectEventRecorded(kOmniboxSetToGoogle, false); |
466 ExpectEventRecorded(kOmniboxFirstSearch, true); | 518 ExpectEventRecorded(kOmniboxFirstSearch, true); |
467 | 519 |
468 // Home page events. | 520 // Home page events. |
469 ExpectEventRecorded(kHomepageInstall, false); | 521 ExpectEventRecorded(kHomepageInstall, false); |
470 ExpectEventRecorded(kHomepageSetToGoogle, false); | 522 ExpectEventRecorded(kHomepageSetToGoogle, false); |
471 ExpectEventRecorded(kHomepageFirstSeach, false); | 523 ExpectEventRecorded(kHomepageFirstSeach, false); |
472 | 524 |
525 // App list events. | |
526 ExpectEventRecorded(kApplistInstall, false); | |
527 ExpectEventRecorded(kApplistSetToGoogle, false); | |
528 ExpectEventRecorded(kApplistFirstSearch, false); | |
529 | |
473 ExpectRlzPingSent(false); | 530 ExpectRlzPingSent(false); |
474 } | 531 } |
475 | 532 |
476 TEST_F(RlzLibTest, HomepageUsageOnly) { | 533 TEST_F(RlzLibTest, HomepageUsageOnly) { |
477 TestRLZTracker::InitRlzDelayed(true, false, kDelay, true, true, false); | 534 TestRLZTracker::InitRlzDelayed(true, false, kDelay, true, true, false); |
478 SimulateHomepageUsage(); | 535 SimulateHomepageUsage(); |
479 | 536 |
480 // Omnibox events. | 537 // Omnibox events. |
481 ExpectEventRecorded(kOmniboxInstall, false); | 538 ExpectEventRecorded(kOmniboxInstall, false); |
482 ExpectEventRecorded(kOmniboxSetToGoogle, false); | 539 ExpectEventRecorded(kOmniboxSetToGoogle, false); |
483 ExpectEventRecorded(kOmniboxFirstSearch, false); | 540 ExpectEventRecorded(kOmniboxFirstSearch, false); |
484 | 541 |
485 // Home page events. | 542 // Home page events. |
486 ExpectEventRecorded(kHomepageInstall, false); | 543 ExpectEventRecorded(kHomepageInstall, false); |
487 ExpectEventRecorded(kHomepageSetToGoogle, false); | 544 ExpectEventRecorded(kHomepageSetToGoogle, false); |
488 ExpectEventRecorded(kHomepageFirstSeach, true); | 545 ExpectEventRecorded(kHomepageFirstSeach, true); |
489 | 546 |
547 // App list events. | |
548 ExpectEventRecorded(kApplistInstall, false); | |
549 ExpectEventRecorded(kApplistSetToGoogle, false); | |
550 ExpectEventRecorded(kApplistFirstSearch, false); | |
551 | |
490 ExpectRlzPingSent(false); | 552 ExpectRlzPingSent(false); |
491 } | 553 } |
492 | 554 |
493 TEST_F(RlzLibTest, UsageBeforeDelayedInit) { | 555 TEST_F(RlzLibTest, UsageBeforeDelayedInit) { |
Roger Tawa OOO till Jul 10th
2014/04/01 14:20:18
Please add a new test called ApplistUsageOnly.
Sam McNally
2014/04/02 01:27:28
Done.
| |
494 TestRLZTracker::InitRlzDelayed(true, false, kDelay, true, true, false); | 556 TestRLZTracker::InitRlzDelayed(true, false, kDelay, true, true, false); |
495 SimulateOmniboxUsage(); | 557 SimulateOmniboxUsage(); |
496 SimulateHomepageUsage(); | 558 SimulateHomepageUsage(); |
497 InvokeDelayedInit(); | 559 InvokeDelayedInit(); |
498 | 560 |
499 // Omnibox events. | 561 // Omnibox events. |
500 ExpectEventRecorded(kOmniboxInstall, true); | 562 ExpectEventRecorded(kOmniboxInstall, true); |
501 ExpectEventRecorded(kOmniboxSetToGoogle, true); | 563 ExpectEventRecorded(kOmniboxSetToGoogle, true); |
502 ExpectEventRecorded(kOmniboxFirstSearch, true); | 564 ExpectEventRecorded(kOmniboxFirstSearch, true); |
503 | 565 |
504 // Home page events. | 566 // Home page events. |
505 ExpectEventRecorded(kHomepageInstall, true); | 567 ExpectEventRecorded(kHomepageInstall, true); |
506 ExpectEventRecorded(kHomepageSetToGoogle, true); | 568 ExpectEventRecorded(kHomepageSetToGoogle, true); |
507 ExpectEventRecorded(kHomepageFirstSeach, true); | 569 ExpectEventRecorded(kHomepageFirstSeach, true); |
508 | 570 |
571 // App list events. | |
572 ExpectEventRecorded(kApplistInstall, true); | |
573 ExpectEventRecorded(kApplistSetToGoogle, true); | |
574 ExpectEventRecorded(kApplistFirstSearch, false); | |
575 | |
509 ExpectRlzPingSent(true); | 576 ExpectRlzPingSent(true); |
510 } | 577 } |
511 | 578 |
512 TEST_F(RlzLibTest, OmniboxUsageAfterDelayedInit) { | 579 TEST_F(RlzLibTest, OmniboxUsageAfterDelayedInit) { |
513 TestRLZTracker::InitRlzDelayed(true, false, kDelay, true, true, false); | 580 TestRLZTracker::InitRlzDelayed(true, false, kDelay, true, true, false); |
514 InvokeDelayedInit(); | 581 InvokeDelayedInit(); |
515 SimulateOmniboxUsage(); | 582 SimulateOmniboxUsage(); |
516 SimulateHomepageUsage(); | 583 SimulateHomepageUsage(); |
517 | 584 |
518 // Omnibox events. | 585 // Omnibox events. |
519 ExpectEventRecorded(kOmniboxInstall, true); | 586 ExpectEventRecorded(kOmniboxInstall, true); |
520 ExpectEventRecorded(kOmniboxSetToGoogle, true); | 587 ExpectEventRecorded(kOmniboxSetToGoogle, true); |
521 ExpectEventRecorded(kOmniboxFirstSearch, true); | 588 ExpectEventRecorded(kOmniboxFirstSearch, true); |
522 | 589 |
523 // Home page events. | 590 // Home page events. |
524 ExpectEventRecorded(kHomepageInstall, true); | 591 ExpectEventRecorded(kHomepageInstall, true); |
525 ExpectEventRecorded(kHomepageSetToGoogle, true); | 592 ExpectEventRecorded(kHomepageSetToGoogle, true); |
526 ExpectEventRecorded(kHomepageFirstSeach, true); | 593 ExpectEventRecorded(kHomepageFirstSeach, true); |
527 | 594 |
595 // App list events. | |
596 ExpectEventRecorded(kApplistInstall, true); | |
597 ExpectEventRecorded(kApplistSetToGoogle, true); | |
598 ExpectEventRecorded(kApplistFirstSearch, false); | |
599 | |
528 ExpectRlzPingSent(true); | 600 ExpectRlzPingSent(true); |
529 } | 601 } |
530 | 602 |
531 TEST_F(RlzLibTest, OmniboxUsageSendsPingWhenSendPingImmediately) { | 603 TEST_F(RlzLibTest, OmniboxUsageSendsPingWhenSendPingImmediately) { |
532 TestRLZTracker::InitRlzDelayed(true, true, kDelay, true, true, false); | 604 TestRLZTracker::InitRlzDelayed(true, true, kDelay, true, true, false); |
533 SimulateOmniboxUsage(); | 605 SimulateOmniboxUsage(); |
534 | 606 |
535 // Omnibox events. | 607 // Omnibox events. |
536 ExpectEventRecorded(kOmniboxInstall, true); | 608 ExpectEventRecorded(kOmniboxInstall, true); |
537 ExpectEventRecorded(kOmniboxSetToGoogle, true); | 609 ExpectEventRecorded(kOmniboxSetToGoogle, true); |
538 ExpectEventRecorded(kOmniboxFirstSearch, true); | 610 ExpectEventRecorded(kOmniboxFirstSearch, true); |
539 | 611 |
540 // Home page events. | 612 // Home page events. |
541 ExpectEventRecorded(kHomepageInstall, true); | 613 ExpectEventRecorded(kHomepageInstall, true); |
542 ExpectEventRecorded(kHomepageSetToGoogle, true); | 614 ExpectEventRecorded(kHomepageSetToGoogle, true); |
543 ExpectEventRecorded(kHomepageFirstSeach, false); | 615 ExpectEventRecorded(kHomepageFirstSeach, false); |
544 | 616 |
617 // App list events. | |
618 ExpectEventRecorded(kApplistInstall, true); | |
619 ExpectEventRecorded(kApplistSetToGoogle, true); | |
620 ExpectEventRecorded(kApplistFirstSearch, false); | |
621 | |
545 ExpectRlzPingSent(true); | 622 ExpectRlzPingSent(true); |
546 } | 623 } |
547 | 624 |
548 TEST_F(RlzLibTest, HomepageUsageDoesNotSendPingWhenSendPingImmediately) { | 625 TEST_F(RlzLibTest, HomepageUsageDoesNotSendPingWhenSendPingImmediately) { |
549 TestRLZTracker::InitRlzDelayed(true, true, kDelay, true, true, false); | 626 TestRLZTracker::InitRlzDelayed(true, true, kDelay, true, true, false); |
550 SimulateHomepageUsage(); | 627 SimulateHomepageUsage(); |
551 | 628 |
552 // Omnibox events. | 629 // Omnibox events. |
553 ExpectEventRecorded(kOmniboxInstall, false); | 630 ExpectEventRecorded(kOmniboxInstall, false); |
554 ExpectEventRecorded(kOmniboxSetToGoogle, false); | 631 ExpectEventRecorded(kOmniboxSetToGoogle, false); |
555 ExpectEventRecorded(kOmniboxFirstSearch, false); | 632 ExpectEventRecorded(kOmniboxFirstSearch, false); |
556 | 633 |
557 // Home page events. | 634 // Home page events. |
558 ExpectEventRecorded(kHomepageInstall, false); | 635 ExpectEventRecorded(kHomepageInstall, false); |
559 ExpectEventRecorded(kHomepageSetToGoogle, false); | 636 ExpectEventRecorded(kHomepageSetToGoogle, false); |
560 ExpectEventRecorded(kHomepageFirstSeach, true); | 637 ExpectEventRecorded(kHomepageFirstSeach, true); |
561 | 638 |
639 // App list events. | |
640 ExpectEventRecorded(kApplistInstall, false); | |
641 ExpectEventRecorded(kApplistSetToGoogle, false); | |
642 ExpectEventRecorded(kApplistFirstSearch, false); | |
643 | |
562 ExpectRlzPingSent(false); | 644 ExpectRlzPingSent(false); |
563 } | 645 } |
564 | 646 |
565 TEST_F(RlzLibTest, StartupUsageDoesNotSendPingWhenSendPingImmediately) { | 647 TEST_F(RlzLibTest, StartupUsageDoesNotSendPingWhenSendPingImmediately) { |
566 TestRLZTracker::InitRlzDelayed(true, true, kDelay, true, false, true); | 648 TestRLZTracker::InitRlzDelayed(true, true, kDelay, true, false, true); |
567 SimulateHomepageUsage(); | 649 SimulateHomepageUsage(); |
568 | 650 |
569 // Omnibox events. | 651 // Omnibox events. |
570 ExpectEventRecorded(kOmniboxInstall, false); | 652 ExpectEventRecorded(kOmniboxInstall, false); |
571 ExpectEventRecorded(kOmniboxSetToGoogle, false); | 653 ExpectEventRecorded(kOmniboxSetToGoogle, false); |
572 ExpectEventRecorded(kOmniboxFirstSearch, false); | 654 ExpectEventRecorded(kOmniboxFirstSearch, false); |
573 | 655 |
574 // Home page events. | 656 // Home page events. |
575 ExpectEventRecorded(kHomepageInstall, false); | 657 ExpectEventRecorded(kHomepageInstall, false); |
576 ExpectEventRecorded(kHomepageSetToGoogle, false); | 658 ExpectEventRecorded(kHomepageSetToGoogle, false); |
577 ExpectEventRecorded(kHomepageFirstSeach, true); | 659 ExpectEventRecorded(kHomepageFirstSeach, true); |
578 | 660 |
661 // App list events. | |
662 ExpectEventRecorded(kApplistInstall, false); | |
663 ExpectEventRecorded(kApplistSetToGoogle, false); | |
664 ExpectEventRecorded(kApplistFirstSearch, false); | |
665 | |
579 ExpectRlzPingSent(false); | 666 ExpectRlzPingSent(false); |
580 } | 667 } |
581 | 668 |
582 TEST_F(RlzLibTest, GetAccessPointRlzOnIoThread) { | 669 TEST_F(RlzLibTest, GetAccessPointRlzOnIoThread) { |
Roger Tawa OOO till Jul 10th
2014/04/01 14:20:18
Please add a new test ApplistUsageDoesNotSendPingW
Sam McNally
2014/04/02 01:27:28
Done.
| |
583 // Set dummy RLZ string. | 670 // Set dummy RLZ string. |
584 rlz_lib::SetAccessPointRlz(RLZTracker::CHROME_OMNIBOX, kOmniboxRlzString); | 671 rlz_lib::SetAccessPointRlz(RLZTracker::CHROME_OMNIBOX, kOmniboxRlzString); |
585 | 672 |
586 base::string16 rlz; | 673 base::string16 rlz; |
587 | 674 |
588 tracker_.set_assume_not_ui_thread(true); | 675 tracker_.set_assume_not_ui_thread(true); |
589 EXPECT_TRUE(RLZTracker::GetAccessPointRlz(RLZTracker::CHROME_OMNIBOX, &rlz)); | 676 EXPECT_TRUE(RLZTracker::GetAccessPointRlz(RLZTracker::CHROME_OMNIBOX, &rlz)); |
590 EXPECT_STREQ(kOmniboxRlzString, base::UTF16ToUTF8(rlz).c_str()); | 677 EXPECT_STREQ(kOmniboxRlzString, base::UTF16ToUTF8(rlz).c_str()); |
591 } | 678 } |
592 | 679 |
(...skipping 22 matching lines...) Expand all Loading... | |
615 | 702 |
616 tracker_.set_assume_not_ui_thread(false); | 703 tracker_.set_assume_not_ui_thread(false); |
617 EXPECT_TRUE(RLZTracker::GetAccessPointRlz(RLZTracker::CHROME_OMNIBOX, &rlz)); | 704 EXPECT_TRUE(RLZTracker::GetAccessPointRlz(RLZTracker::CHROME_OMNIBOX, &rlz)); |
618 EXPECT_STREQ(kOmniboxRlzString, base::UTF16ToUTF8(rlz).c_str()); | 705 EXPECT_STREQ(kOmniboxRlzString, base::UTF16ToUTF8(rlz).c_str()); |
619 } | 706 } |
620 | 707 |
621 TEST_F(RlzLibTest, PingUpdatesRlzCache) { | 708 TEST_F(RlzLibTest, PingUpdatesRlzCache) { |
622 // Set dummy RLZ string. | 709 // Set dummy RLZ string. |
623 rlz_lib::SetAccessPointRlz(RLZTracker::CHROME_OMNIBOX, kOmniboxRlzString); | 710 rlz_lib::SetAccessPointRlz(RLZTracker::CHROME_OMNIBOX, kOmniboxRlzString); |
624 rlz_lib::SetAccessPointRlz(RLZTracker::CHROME_HOME_PAGE, kHomepageRlzString); | 711 rlz_lib::SetAccessPointRlz(RLZTracker::CHROME_HOME_PAGE, kHomepageRlzString); |
712 rlz_lib::SetAccessPointRlz(RLZTracker::CHROME_APP_LIST, kApplistRlzString); | |
625 | 713 |
626 base::string16 rlz; | 714 base::string16 rlz; |
627 | 715 |
628 // Prime the cache. | 716 // Prime the cache. |
629 tracker_.set_assume_not_ui_thread(true); | 717 tracker_.set_assume_not_ui_thread(true); |
630 | 718 |
631 EXPECT_TRUE(RLZTracker::GetAccessPointRlz(RLZTracker::CHROME_OMNIBOX, &rlz)); | 719 EXPECT_TRUE(RLZTracker::GetAccessPointRlz(RLZTracker::CHROME_OMNIBOX, &rlz)); |
632 EXPECT_STREQ(kOmniboxRlzString, base::UTF16ToUTF8(rlz).c_str()); | 720 EXPECT_STREQ(kOmniboxRlzString, base::UTF16ToUTF8(rlz).c_str()); |
633 EXPECT_TRUE(RLZTracker::GetAccessPointRlz( | 721 EXPECT_TRUE(RLZTracker::GetAccessPointRlz( |
634 RLZTracker::CHROME_HOME_PAGE, &rlz)); | 722 RLZTracker::CHROME_HOME_PAGE, &rlz)); |
635 EXPECT_STREQ(kHomepageRlzString, base::UTF16ToUTF8(rlz).c_str()); | 723 EXPECT_STREQ(kHomepageRlzString, base::UTF16ToUTF8(rlz).c_str()); |
724 EXPECT_TRUE(RLZTracker::GetAccessPointRlz(RLZTracker::CHROME_APP_LIST, &rlz)); | |
725 EXPECT_STREQ(kApplistRlzString, base::UTF16ToUTF8(rlz).c_str()); | |
636 | 726 |
637 // Make sure cache is valid. | 727 // Make sure cache is valid. |
638 tracker_.set_assume_not_ui_thread(false); | 728 tracker_.set_assume_not_ui_thread(false); |
639 | 729 |
640 EXPECT_TRUE(RLZTracker::GetAccessPointRlz(RLZTracker::CHROME_OMNIBOX, &rlz)); | 730 EXPECT_TRUE(RLZTracker::GetAccessPointRlz(RLZTracker::CHROME_OMNIBOX, &rlz)); |
641 EXPECT_STREQ(kOmniboxRlzString, base::UTF16ToUTF8(rlz).c_str()); | 731 EXPECT_STREQ(kOmniboxRlzString, base::UTF16ToUTF8(rlz).c_str()); |
642 EXPECT_TRUE(RLZTracker::GetAccessPointRlz( | 732 EXPECT_TRUE(RLZTracker::GetAccessPointRlz( |
643 RLZTracker::CHROME_HOME_PAGE, &rlz)); | 733 RLZTracker::CHROME_HOME_PAGE, &rlz)); |
644 EXPECT_STREQ(kHomepageRlzString, base::UTF16ToUTF8(rlz).c_str()); | 734 EXPECT_STREQ(kHomepageRlzString, base::UTF16ToUTF8(rlz).c_str()); |
735 EXPECT_TRUE(RLZTracker::GetAccessPointRlz(RLZTracker::CHROME_APP_LIST, &rlz)); | |
736 EXPECT_STREQ(kApplistRlzString, base::UTF16ToUTF8(rlz).c_str()); | |
645 | 737 |
646 // Perform ping. | 738 // Perform ping. |
647 tracker_.set_assume_not_ui_thread(true); | 739 tracker_.set_assume_not_ui_thread(true); |
648 TestRLZTracker::InitRlzDelayed(true, false, kDelay, true, true, false); | 740 TestRLZTracker::InitRlzDelayed(true, false, kDelay, true, true, false); |
649 InvokeDelayedInit(); | 741 InvokeDelayedInit(); |
650 ExpectRlzPingSent(true); | 742 ExpectRlzPingSent(true); |
651 | 743 |
652 // Make sure cache is now updated. | 744 // Make sure cache is now updated. |
653 tracker_.set_assume_not_ui_thread(false); | 745 tracker_.set_assume_not_ui_thread(false); |
654 | 746 |
655 EXPECT_TRUE(RLZTracker::GetAccessPointRlz(RLZTracker::CHROME_OMNIBOX, &rlz)); | 747 EXPECT_TRUE(RLZTracker::GetAccessPointRlz(RLZTracker::CHROME_OMNIBOX, &rlz)); |
656 EXPECT_STREQ(kNewOmniboxRlzString, base::UTF16ToUTF8(rlz).c_str()); | 748 EXPECT_STREQ(kNewOmniboxRlzString, base::UTF16ToUTF8(rlz).c_str()); |
657 EXPECT_TRUE(RLZTracker::GetAccessPointRlz( | 749 EXPECT_TRUE(RLZTracker::GetAccessPointRlz( |
658 RLZTracker::CHROME_HOME_PAGE, &rlz)); | 750 RLZTracker::CHROME_HOME_PAGE, &rlz)); |
659 EXPECT_STREQ(kNewHomepageRlzString, base::UTF16ToUTF8(rlz).c_str()); | 751 EXPECT_STREQ(kNewHomepageRlzString, base::UTF16ToUTF8(rlz).c_str()); |
752 EXPECT_TRUE(RLZTracker::GetAccessPointRlz(RLZTracker::CHROME_APP_LIST, &rlz)); | |
753 EXPECT_STREQ(kNewApplistRlzString, base::UTF16ToUTF8(rlz).c_str()); | |
660 } | 754 } |
661 | 755 |
662 TEST_F(RlzLibTest, ObserveHandlesBadArgs) { | 756 TEST_F(RlzLibTest, ObserveHandlesBadArgs) { |
663 scoped_ptr<NavigationEntry> entry(NavigationEntry::Create()); | 757 scoped_ptr<NavigationEntry> entry(NavigationEntry::Create()); |
664 entry->SetPageID(0); | 758 entry->SetPageID(0); |
665 entry->SetTransitionType(content::PAGE_TRANSITION_LINK); | 759 entry->SetTransitionType(content::PAGE_TRANSITION_LINK); |
666 tracker_.Observe(content::NOTIFICATION_NAV_ENTRY_PENDING, | 760 tracker_.Observe(content::NOTIFICATION_NAV_ENTRY_PENDING, |
667 content::NotificationService::AllSources(), | 761 content::NotificationService::AllSources(), |
668 content::Details<NavigationEntry>(NULL)); | 762 content::Details<NavigationEntry>(NULL)); |
669 tracker_.Observe(content::NOTIFICATION_NAV_ENTRY_PENDING, | 763 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, | 816 RLZTracker::RecordProductEvent(rlz_lib::CHROME, RLZTracker::CHROME_OMNIBOX, |
723 rlz_lib::FIRST_SEARCH); | 817 rlz_lib::FIRST_SEARCH); |
724 | 818 |
725 ExpectEventRecorded(kOmniboxFirstSearch, true); | 819 ExpectEventRecorded(kOmniboxFirstSearch, true); |
726 | 820 |
727 RLZTracker::ClearRlzState(); | 821 RLZTracker::ClearRlzState(); |
728 | 822 |
729 ExpectEventRecorded(kOmniboxFirstSearch, false); | 823 ExpectEventRecorded(kOmniboxFirstSearch, false); |
730 } | 824 } |
731 #endif // defined(OS_CHROMEOS) | 825 #endif // defined(OS_CHROMEOS) |
OLD | NEW |