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/stringprintf.h" | 8 #include "base/stringprintf.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 #include "base/scoped_temp_dir.h" | 10 #include "base/scoped_temp_dir.h" |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 | 131 |
132 virtual bool SendFinancialPing(const std::string& brand, | 132 virtual bool SendFinancialPing(const std::string& brand, |
133 const string16& lang, | 133 const string16& lang, |
134 const string16& referral) OVERRIDE { | 134 const string16& referral) OVERRIDE { |
135 // Don't ping the server during tests, just pretend as if we did. | 135 // Don't ping the server during tests, just pretend as if we did. |
136 EXPECT_FALSE(brand.empty()); | 136 EXPECT_FALSE(brand.empty()); |
137 pinged_brands_.insert(brand); | 137 pinged_brands_.insert(brand); |
138 | 138 |
139 // Set new access points RLZ string, like the actual server ping would have | 139 // Set new access points RLZ string, like the actual server ping would have |
140 // done. | 140 // done. |
141 rlz_lib::SetAccessPointRlz(rlz_lib::CHROME_OMNIBOX, kNewOmniboxRlzString); | 141 rlz_lib::SetAccessPointRlz(RLZTracker::CHROME_OMNIBOX, |
142 rlz_lib::SetAccessPointRlz(rlz_lib::CHROME_HOME_PAGE, | 142 kNewOmniboxRlzString); |
| 143 rlz_lib::SetAccessPointRlz(RLZTracker::CHROME_HOME_PAGE, |
143 kNewHomepageRlzString); | 144 kNewHomepageRlzString); |
144 return true; | 145 return true; |
145 } | 146 } |
146 | 147 |
147 std::set<std::string> pinged_brands_; | 148 std::set<std::string> pinged_brands_; |
148 bool assume_not_ui_thread_; | 149 bool assume_not_ui_thread_; |
149 | 150 |
150 DISALLOW_COPY_AND_ASSIGN(TestRLZTracker); | 151 DISALLOW_COPY_AND_ASSIGN(TestRLZTracker); |
151 }; | 152 }; |
152 | 153 |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 google_util::GetBrand(&brand); | 302 google_util::GetBrand(&brand); |
302 EXPECT_EQ(expected, tracker_.was_ping_sent_for_brand(brand.c_str())); | 303 EXPECT_EQ(expected, tracker_.was_ping_sent_for_brand(brand.c_str())); |
303 } | 304 } |
304 | 305 |
305 void RlzLibTest::ExpectReactivationRlzPingSent(bool expected) { | 306 void RlzLibTest::ExpectReactivationRlzPingSent(bool expected) { |
306 std::string brand; | 307 std::string brand; |
307 google_util::GetReactivationBrand(&brand); | 308 google_util::GetReactivationBrand(&brand); |
308 EXPECT_EQ(expected, tracker_.was_ping_sent_for_brand(brand.c_str())); | 309 EXPECT_EQ(expected, tracker_.was_ping_sent_for_brand(brand.c_str())); |
309 } | 310 } |
310 | 311 |
311 TEST_F(RlzLibTest, RecordProductEvent) { | |
312 RLZTracker::RecordProductEvent(rlz_lib::CHROME, rlz_lib::CHROME_OMNIBOX, | |
313 rlz_lib::FIRST_SEARCH); | |
314 | |
315 ExpectEventRecorded("C1F", true); | |
316 } | |
317 | |
318 // The events that affect the different RLZ scenarios are the following: | 312 // The events that affect the different RLZ scenarios are the following: |
319 // | 313 // |
320 // A: the user starts chrome for the first time | 314 // A: the user starts chrome for the first time |
321 // B: the user stops chrome | 315 // B: the user stops chrome |
322 // C: the user start a subsequent time | 316 // C: the user start a subsequent time |
323 // D: the user stops chrome again | 317 // D: the user stops chrome again |
324 // I: the RLZTracker::DelayedInit() method is invoked | 318 // I: the RLZTracker::DelayedInit() method is invoked |
325 // X: the user performs a search using the omnibox | 319 // X: the user performs a search using the omnibox |
326 // Y: the user performs a search using the home page | 320 // Y: the user performs a search using the home page |
327 // | 321 // |
328 // The events A to D happen in chronological order, but the other events | 322 // The events A to D happen in chronological order, but the other events |
329 // may happen at any point between A-B or C-D, in no particular order. | 323 // may happen at any point between A-B or C-D, in no particular order. |
330 // | 324 // |
331 // The visible results of the scenarios are: | 325 // The visible results of the scenarios are: |
332 // | 326 // |
333 // C1I event is recorded | 327 // C1I event is recorded |
334 // C2I event is recorded | 328 // C2I event is recorded |
335 // C1F event is recorded | 329 // C1F event is recorded |
336 // C2F event is recorded | 330 // C2F event is recorded |
337 // C1S event is recorded | 331 // C1S event is recorded |
338 // C2S event is recorded | 332 // C2S event is recorded |
339 // RLZ ping sent | 333 // RLZ ping sent |
340 // | 334 // |
| 335 // On Mac, C5 / C6 are sent instead of C1 / C2. |
| 336 // |
341 // Variations on the above scenarios: | 337 // Variations on the above scenarios: |
342 // | 338 // |
343 // - if the delay specified to InitRlzDelayed() is negative, then the RLZ | 339 // - if the delay specified to InitRlzDelayed() is negative, then the RLZ |
344 // ping should be sent out at the time of event X and not wait for I | 340 // ping should be sent out at the time of event X and not wait for I |
345 // | 341 // |
346 // Also want to test that pre-warming the RLZ string cache works correctly. | 342 // Also want to test that pre-warming the RLZ string cache works correctly. |
347 | 343 |
| 344 #if !defined(OS_MACOSX) |
| 345 const char kC1I[] = "C1I"; |
| 346 const char kC1S[] = "C1S"; |
| 347 const char kC1F[] = "C1F"; |
| 348 |
| 349 const char kC2I[] = "C2I"; |
| 350 const char kC2S[] = "C2S"; |
| 351 const char kC2F[] = "C2F"; |
| 352 #else |
| 353 const char kC1I[] = "C5I"; |
| 354 const char kC1S[] = "C5S"; |
| 355 const char kC1F[] = "C5F"; |
| 356 |
| 357 const char kC2I[] = "C6I"; |
| 358 const char kC2S[] = "C6S"; |
| 359 const char kC2F[] = "C6F"; |
| 360 #endif |
| 361 |
| 362 TEST_F(RlzLibTest, RecordProductEvent) { |
| 363 RLZTracker::RecordProductEvent(rlz_lib::CHROME, RLZTracker::CHROME_OMNIBOX, |
| 364 rlz_lib::FIRST_SEARCH); |
| 365 |
| 366 ExpectEventRecorded(kC1F, true); |
| 367 } |
| 368 |
348 TEST_F(RlzLibTest, QuickStopAfterStart) { | 369 TEST_F(RlzLibTest, QuickStopAfterStart) { |
349 RLZTracker::InitRlzDelayed(true, 20, true, true); | 370 RLZTracker::InitRlzDelayed(true, 20, true, true); |
350 | 371 |
351 // Omnibox events. | 372 // Omnibox events. |
352 ExpectEventRecorded("C1I", false); | 373 ExpectEventRecorded(kC1I, false); |
353 ExpectEventRecorded("C1S", false); | 374 ExpectEventRecorded(kC1S, false); |
354 ExpectEventRecorded("C1F", false); | 375 ExpectEventRecorded(kC1F, false); |
355 | 376 |
356 // Home page events. | 377 // Home page events. |
357 ExpectEventRecorded("C2I", false); | 378 ExpectEventRecorded(kC2I, false); |
358 ExpectEventRecorded("C2S", false); | 379 ExpectEventRecorded(kC2S, false); |
359 ExpectEventRecorded("C2F", false); | 380 ExpectEventRecorded(kC2F, false); |
360 | 381 |
361 ExpectRlzPingSent(false); | 382 ExpectRlzPingSent(false); |
362 } | 383 } |
363 | 384 |
364 TEST_F(RlzLibTest, DelayedInitOnly) { | 385 TEST_F(RlzLibTest, DelayedInitOnly) { |
365 RLZTracker::InitRlzDelayed(true, 20, true, true); | 386 RLZTracker::InitRlzDelayed(true, 20, true, true); |
366 InvokeDelayedInit(); | 387 InvokeDelayedInit(); |
367 | 388 |
368 // Omnibox events. | 389 // Omnibox events. |
369 ExpectEventRecorded("C1I", true); | 390 ExpectEventRecorded(kC1I, true); |
370 ExpectEventRecorded("C1S", true); | 391 ExpectEventRecorded(kC1S, true); |
371 ExpectEventRecorded("C1F", false); | 392 ExpectEventRecorded(kC1F, false); |
372 | 393 |
373 // Home page events. | 394 // Home page events. |
374 ExpectEventRecorded("C2I", true); | 395 ExpectEventRecorded(kC2I, true); |
375 ExpectEventRecorded("C2S", true); | 396 ExpectEventRecorded(kC2S, true); |
376 ExpectEventRecorded("C2F", false); | 397 ExpectEventRecorded(kC2F, false); |
377 | 398 |
378 ExpectRlzPingSent(true); | 399 ExpectRlzPingSent(true); |
379 } | 400 } |
380 | 401 |
381 TEST_F(RlzLibTest, DelayedInitOnlyNoFirstRunNoRlzStrings) { | 402 TEST_F(RlzLibTest, DelayedInitOnlyNoFirstRunNoRlzStrings) { |
382 RLZTracker::InitRlzDelayed(false, 20, true, true); | 403 RLZTracker::InitRlzDelayed(false, 20, true, true); |
383 InvokeDelayedInit(); | 404 InvokeDelayedInit(); |
384 | 405 |
385 // Omnibox events. | 406 // Omnibox events. |
386 ExpectEventRecorded("C1I", true); | 407 ExpectEventRecorded(kC1I, true); |
387 ExpectEventRecorded("C1S", true); | 408 ExpectEventRecorded(kC1S, true); |
388 ExpectEventRecorded("C1F", false); | 409 ExpectEventRecorded(kC1F, false); |
389 | 410 |
390 // Home page events. | 411 // Home page events. |
391 ExpectEventRecorded("C2I", true); | 412 ExpectEventRecorded(kC2I, true); |
392 ExpectEventRecorded("C2S", true); | 413 ExpectEventRecorded(kC2S, true); |
393 ExpectEventRecorded("C2F", false); | 414 ExpectEventRecorded(kC2F, false); |
394 | 415 |
395 ExpectRlzPingSent(true); | 416 ExpectRlzPingSent(true); |
396 } | 417 } |
397 | 418 |
398 TEST_F(RlzLibTest, DelayedInitOnlyNoFirstRun) { | 419 TEST_F(RlzLibTest, DelayedInitOnlyNoFirstRun) { |
399 // Set some dummy RLZ strings to simulate that we already ran before and | 420 // Set some dummy RLZ strings to simulate that we already ran before and |
400 // performed a successful ping to the RLZ server. | 421 // performed a successful ping to the RLZ server. |
401 rlz_lib::SetAccessPointRlz(rlz_lib::CHROME_OMNIBOX, kOmniboxRlzString); | 422 rlz_lib::SetAccessPointRlz(RLZTracker::CHROME_OMNIBOX, kOmniboxRlzString); |
402 rlz_lib::SetAccessPointRlz(rlz_lib::CHROME_HOME_PAGE, kHomepageRlzString); | 423 rlz_lib::SetAccessPointRlz(RLZTracker::CHROME_HOME_PAGE, kHomepageRlzString); |
403 | 424 |
404 RLZTracker::InitRlzDelayed(false, 20, true, true); | 425 RLZTracker::InitRlzDelayed(false, 20, true, true); |
405 InvokeDelayedInit(); | 426 InvokeDelayedInit(); |
406 | 427 |
407 // Omnibox events. | 428 // Omnibox events. |
408 ExpectEventRecorded("C1I", true); | 429 ExpectEventRecorded(kC1I, true); |
409 ExpectEventRecorded("C1S", false); | 430 ExpectEventRecorded(kC1S, false); |
410 ExpectEventRecorded("C1F", false); | 431 ExpectEventRecorded(kC1F, false); |
411 | 432 |
412 // Home page events. | 433 // Home page events. |
413 ExpectEventRecorded("C2I", true); | 434 ExpectEventRecorded(kC2I, true); |
414 ExpectEventRecorded("C2S", false); | 435 ExpectEventRecorded(kC2S, false); |
415 ExpectEventRecorded("C2F", false); | 436 ExpectEventRecorded(kC2F, false); |
416 | 437 |
417 ExpectRlzPingSent(true); | 438 ExpectRlzPingSent(true); |
418 } | 439 } |
419 | 440 |
420 TEST_F(RlzLibTest, DelayedInitOnlyNoGoogleDefaultSearchOrHomepage) { | 441 TEST_F(RlzLibTest, DelayedInitOnlyNoGoogleDefaultSearchOrHomepage) { |
421 RLZTracker::InitRlzDelayed(true, 20, false, false); | 442 RLZTracker::InitRlzDelayed(true, 20, false, false); |
422 InvokeDelayedInit(); | 443 InvokeDelayedInit(); |
423 | 444 |
424 // Omnibox events. | 445 // Omnibox events. |
425 ExpectEventRecorded("C1I", true); | 446 ExpectEventRecorded(kC1I, true); |
426 ExpectEventRecorded("C1S", false); | 447 ExpectEventRecorded(kC1S, false); |
427 ExpectEventRecorded("C1F", false); | 448 ExpectEventRecorded(kC1F, false); |
428 | 449 |
429 // Home page events. | 450 // Home page events. |
430 ExpectEventRecorded("C2I", true); | 451 ExpectEventRecorded(kC2I, true); |
431 ExpectEventRecorded("C2S", false); | 452 ExpectEventRecorded(kC2S, false); |
432 ExpectEventRecorded("C2F", false); | 453 ExpectEventRecorded(kC2F, false); |
433 | 454 |
434 ExpectRlzPingSent(true); | 455 ExpectRlzPingSent(true); |
435 } | 456 } |
436 | 457 |
437 TEST_F(RlzLibTest, OmniboxUsageOnly) { | 458 TEST_F(RlzLibTest, OmniboxUsageOnly) { |
438 RLZTracker::InitRlzDelayed(true, 20, true, true); | 459 RLZTracker::InitRlzDelayed(true, 20, true, true); |
439 SimulateOmniboxUsage(); | 460 SimulateOmniboxUsage(); |
440 | 461 |
441 // Omnibox events. | 462 // Omnibox events. |
442 ExpectEventRecorded("C1I", false); | 463 ExpectEventRecorded(kC1I, false); |
443 ExpectEventRecorded("C1S", false); | 464 ExpectEventRecorded(kC1S, false); |
444 ExpectEventRecorded("C1F", true); | 465 ExpectEventRecorded(kC1F, true); |
445 | 466 |
446 // Home page events. | 467 // Home page events. |
447 ExpectEventRecorded("C2I", false); | 468 ExpectEventRecorded(kC2I, false); |
448 ExpectEventRecorded("C2S", false); | 469 ExpectEventRecorded(kC2S, false); |
449 ExpectEventRecorded("C2F", false); | 470 ExpectEventRecorded(kC2F, false); |
450 | 471 |
451 ExpectRlzPingSent(false); | 472 ExpectRlzPingSent(false); |
452 } | 473 } |
453 | 474 |
454 TEST_F(RlzLibTest, HomepageUsageOnly) { | 475 TEST_F(RlzLibTest, HomepageUsageOnly) { |
455 RLZTracker::InitRlzDelayed(true, 20, true, true); | 476 RLZTracker::InitRlzDelayed(true, 20, true, true); |
456 SimulateHomepageUsage(); | 477 SimulateHomepageUsage(); |
457 | 478 |
458 // Omnibox events. | 479 // Omnibox events. |
459 ExpectEventRecorded("C1I", false); | 480 ExpectEventRecorded(kC1I, false); |
460 ExpectEventRecorded("C1S", false); | 481 ExpectEventRecorded(kC1S, false); |
461 ExpectEventRecorded("C1F", false); | 482 ExpectEventRecorded(kC1F, false); |
462 | 483 |
463 // Home page events. | 484 // Home page events. |
464 ExpectEventRecorded("C2I", false); | 485 ExpectEventRecorded(kC2I, false); |
465 ExpectEventRecorded("C2S", false); | 486 ExpectEventRecorded(kC2S, false); |
466 ExpectEventRecorded("C2F", true); | 487 ExpectEventRecorded(kC2F, true); |
467 | 488 |
468 ExpectRlzPingSent(false); | 489 ExpectRlzPingSent(false); |
469 } | 490 } |
470 | 491 |
471 TEST_F(RlzLibTest, UsageBeforeDelayedInit) { | 492 TEST_F(RlzLibTest, UsageBeforeDelayedInit) { |
472 RLZTracker::InitRlzDelayed(true, 20, true, true); | 493 RLZTracker::InitRlzDelayed(true, 20, true, true); |
473 SimulateOmniboxUsage(); | 494 SimulateOmniboxUsage(); |
474 SimulateHomepageUsage(); | 495 SimulateHomepageUsage(); |
475 InvokeDelayedInit(); | 496 InvokeDelayedInit(); |
476 | 497 |
477 // Omnibox events. | 498 // Omnibox events. |
478 ExpectEventRecorded("C1I", true); | 499 ExpectEventRecorded(kC1I, true); |
479 ExpectEventRecorded("C1S", true); | 500 ExpectEventRecorded(kC1S, true); |
480 ExpectEventRecorded("C1F", true); | 501 ExpectEventRecorded(kC1F, true); |
481 | 502 |
482 // Home page events. | 503 // Home page events. |
483 ExpectEventRecorded("C2I", true); | 504 ExpectEventRecorded(kC2I, true); |
484 ExpectEventRecorded("C2S", true); | 505 ExpectEventRecorded(kC2S, true); |
485 ExpectEventRecorded("C2F", true); | 506 ExpectEventRecorded(kC2F, true); |
486 | 507 |
487 ExpectRlzPingSent(true); | 508 ExpectRlzPingSent(true); |
488 } | 509 } |
489 | 510 |
490 TEST_F(RlzLibTest, OmniboxUsageAfterDelayedInit) { | 511 TEST_F(RlzLibTest, OmniboxUsageAfterDelayedInit) { |
491 RLZTracker::InitRlzDelayed(true, 20, true, true); | 512 RLZTracker::InitRlzDelayed(true, 20, true, true); |
492 InvokeDelayedInit(); | 513 InvokeDelayedInit(); |
493 SimulateOmniboxUsage(); | 514 SimulateOmniboxUsage(); |
494 SimulateHomepageUsage(); | 515 SimulateHomepageUsage(); |
495 | 516 |
496 // Omnibox events. | 517 // Omnibox events. |
497 ExpectEventRecorded("C1I", true); | 518 ExpectEventRecorded(kC1I, true); |
498 ExpectEventRecorded("C1S", true); | 519 ExpectEventRecorded(kC1S, true); |
499 ExpectEventRecorded("C1F", true); | 520 ExpectEventRecorded(kC1F, true); |
500 | 521 |
501 // Home page events. | 522 // Home page events. |
502 ExpectEventRecorded("C2I", true); | 523 ExpectEventRecorded(kC2I, true); |
503 ExpectEventRecorded("C2S", true); | 524 ExpectEventRecorded(kC2S, true); |
504 ExpectEventRecorded("C2F", true); | 525 ExpectEventRecorded(kC2F, true); |
505 | 526 |
506 ExpectRlzPingSent(true); | 527 ExpectRlzPingSent(true); |
507 } | 528 } |
508 | 529 |
509 TEST_F(RlzLibTest, OmniboxUsageSendsPingWhenDelayNegative) { | 530 TEST_F(RlzLibTest, OmniboxUsageSendsPingWhenDelayNegative) { |
510 RLZTracker::InitRlzDelayed(true, -20, true, true); | 531 RLZTracker::InitRlzDelayed(true, -20, true, true); |
511 SimulateOmniboxUsage(); | 532 SimulateOmniboxUsage(); |
512 | 533 |
513 // Omnibox events. | 534 // Omnibox events. |
514 ExpectEventRecorded("C1I", true); | 535 ExpectEventRecorded(kC1I, true); |
515 ExpectEventRecorded("C1S", true); | 536 ExpectEventRecorded(kC1S, true); |
516 ExpectEventRecorded("C1F", true); | 537 ExpectEventRecorded(kC1F, true); |
517 | 538 |
518 // Home page events. | 539 // Home page events. |
519 ExpectEventRecorded("C2I", true); | 540 ExpectEventRecorded(kC2I, true); |
520 ExpectEventRecorded("C2S", true); | 541 ExpectEventRecorded(kC2S, true); |
521 ExpectEventRecorded("C2F", false); | 542 ExpectEventRecorded(kC2F, false); |
522 | 543 |
523 ExpectRlzPingSent(true); | 544 ExpectRlzPingSent(true); |
524 } | 545 } |
525 | 546 |
526 TEST_F(RlzLibTest, HomepageUsageDoesNotSendPingWhenDelayNegative) { | 547 TEST_F(RlzLibTest, HomepageUsageDoesNotSendPingWhenDelayNegative) { |
527 RLZTracker::InitRlzDelayed(true, -20, true, true); | 548 RLZTracker::InitRlzDelayed(true, -20, true, true); |
528 SimulateHomepageUsage(); | 549 SimulateHomepageUsage(); |
529 | 550 |
530 // Omnibox events. | 551 // Omnibox events. |
531 ExpectEventRecorded("C1I", false); | 552 ExpectEventRecorded(kC1I, false); |
532 ExpectEventRecorded("C1S", false); | 553 ExpectEventRecorded(kC1S, false); |
533 ExpectEventRecorded("C1F", false); | 554 ExpectEventRecorded(kC1F, false); |
534 | 555 |
535 // Home page events. | 556 // Home page events. |
536 ExpectEventRecorded("C2I", false); | 557 ExpectEventRecorded(kC2I, false); |
537 ExpectEventRecorded("C2S", false); | 558 ExpectEventRecorded(kC2S, false); |
538 ExpectEventRecorded("C2F", true); | 559 ExpectEventRecorded(kC2F, true); |
539 | 560 |
540 ExpectRlzPingSent(false); | 561 ExpectRlzPingSent(false); |
541 } | 562 } |
542 | 563 |
543 TEST_F(RlzLibTest, GetAccessPointRlzOnIoThread) { | 564 TEST_F(RlzLibTest, GetAccessPointRlzOnIoThread) { |
544 // Set dummy RLZ string. | 565 // Set dummy RLZ string. |
545 rlz_lib::SetAccessPointRlz(rlz_lib::CHROME_OMNIBOX, kOmniboxRlzString); | 566 rlz_lib::SetAccessPointRlz(RLZTracker::CHROME_OMNIBOX, kOmniboxRlzString); |
546 | 567 |
547 string16 rlz; | 568 string16 rlz; |
548 | 569 |
549 tracker_.set_assume_not_ui_thread(true); | 570 tracker_.set_assume_not_ui_thread(true); |
550 EXPECT_TRUE(RLZTracker::GetAccessPointRlz(rlz_lib::CHROME_OMNIBOX, &rlz)); | 571 EXPECT_TRUE(RLZTracker::GetAccessPointRlz(RLZTracker::CHROME_OMNIBOX, &rlz)); |
551 EXPECT_STREQ(kOmniboxRlzString, UTF16ToUTF8(rlz).c_str()); | 572 EXPECT_STREQ(kOmniboxRlzString, UTF16ToUTF8(rlz).c_str()); |
552 } | 573 } |
553 | 574 |
554 TEST_F(RlzLibTest, GetAccessPointRlzNotOnIoThread) { | 575 TEST_F(RlzLibTest, GetAccessPointRlzNotOnIoThread) { |
555 // Set dummy RLZ string. | 576 // Set dummy RLZ string. |
556 rlz_lib::SetAccessPointRlz(rlz_lib::CHROME_OMNIBOX, kOmniboxRlzString); | 577 rlz_lib::SetAccessPointRlz(RLZTracker::CHROME_OMNIBOX, kOmniboxRlzString); |
557 | 578 |
558 string16 rlz; | 579 string16 rlz; |
559 | 580 |
560 tracker_.set_assume_not_ui_thread(false); | 581 tracker_.set_assume_not_ui_thread(false); |
561 EXPECT_FALSE(RLZTracker::GetAccessPointRlz(rlz_lib::CHROME_OMNIBOX, &rlz)); | 582 EXPECT_FALSE(RLZTracker::GetAccessPointRlz(RLZTracker::CHROME_OMNIBOX, &rlz)); |
562 } | 583 } |
563 | 584 |
564 TEST_F(RlzLibTest, GetAccessPointRlzIsCached) { | 585 TEST_F(RlzLibTest, GetAccessPointRlzIsCached) { |
565 // Set dummy RLZ string. | 586 // Set dummy RLZ string. |
566 rlz_lib::SetAccessPointRlz(rlz_lib::CHROME_OMNIBOX, kOmniboxRlzString); | 587 rlz_lib::SetAccessPointRlz(RLZTracker::CHROME_OMNIBOX, kOmniboxRlzString); |
567 | 588 |
568 string16 rlz; | 589 string16 rlz; |
569 | 590 |
570 tracker_.set_assume_not_ui_thread(false); | 591 tracker_.set_assume_not_ui_thread(false); |
571 EXPECT_FALSE(RLZTracker::GetAccessPointRlz(rlz_lib::CHROME_OMNIBOX, &rlz)); | 592 EXPECT_FALSE(RLZTracker::GetAccessPointRlz(RLZTracker::CHROME_OMNIBOX, &rlz)); |
572 | 593 |
573 tracker_.set_assume_not_ui_thread(true); | 594 tracker_.set_assume_not_ui_thread(true); |
574 EXPECT_TRUE(RLZTracker::GetAccessPointRlz(rlz_lib::CHROME_OMNIBOX, &rlz)); | 595 EXPECT_TRUE(RLZTracker::GetAccessPointRlz(RLZTracker::CHROME_OMNIBOX, &rlz)); |
575 EXPECT_STREQ(kOmniboxRlzString, UTF16ToUTF8(rlz).c_str()); | 596 EXPECT_STREQ(kOmniboxRlzString, UTF16ToUTF8(rlz).c_str()); |
576 | 597 |
577 tracker_.set_assume_not_ui_thread(false); | 598 tracker_.set_assume_not_ui_thread(false); |
578 EXPECT_TRUE(RLZTracker::GetAccessPointRlz(rlz_lib::CHROME_OMNIBOX, &rlz)); | 599 EXPECT_TRUE(RLZTracker::GetAccessPointRlz(RLZTracker::CHROME_OMNIBOX, &rlz)); |
579 EXPECT_STREQ(kOmniboxRlzString, UTF16ToUTF8(rlz).c_str()); | 600 EXPECT_STREQ(kOmniboxRlzString, UTF16ToUTF8(rlz).c_str()); |
580 } | 601 } |
581 | 602 |
582 TEST_F(RlzLibTest, PingUpdatesRlzCache) { | 603 TEST_F(RlzLibTest, PingUpdatesRlzCache) { |
583 // Set dummy RLZ string. | 604 // Set dummy RLZ string. |
584 rlz_lib::SetAccessPointRlz(rlz_lib::CHROME_OMNIBOX, kOmniboxRlzString); | 605 rlz_lib::SetAccessPointRlz(RLZTracker::CHROME_OMNIBOX, kOmniboxRlzString); |
585 rlz_lib::SetAccessPointRlz(rlz_lib::CHROME_HOME_PAGE, kHomepageRlzString); | 606 rlz_lib::SetAccessPointRlz(RLZTracker::CHROME_HOME_PAGE, kHomepageRlzString); |
586 | 607 |
587 string16 rlz; | 608 string16 rlz; |
588 | 609 |
589 // Prime the cache. | 610 // Prime the cache. |
590 tracker_.set_assume_not_ui_thread(true); | 611 tracker_.set_assume_not_ui_thread(true); |
591 | 612 |
592 EXPECT_TRUE(RLZTracker::GetAccessPointRlz(rlz_lib::CHROME_OMNIBOX, &rlz)); | 613 EXPECT_TRUE(RLZTracker::GetAccessPointRlz(RLZTracker::CHROME_OMNIBOX, &rlz)); |
593 EXPECT_STREQ(kOmniboxRlzString, UTF16ToUTF8(rlz).c_str()); | 614 EXPECT_STREQ(kOmniboxRlzString, UTF16ToUTF8(rlz).c_str()); |
594 EXPECT_TRUE(RLZTracker::GetAccessPointRlz(rlz_lib::CHROME_HOME_PAGE, &rlz)); | 615 EXPECT_TRUE(RLZTracker::GetAccessPointRlz( |
| 616 RLZTracker::CHROME_HOME_PAGE, &rlz)); |
595 EXPECT_STREQ(kHomepageRlzString, UTF16ToUTF8(rlz).c_str()); | 617 EXPECT_STREQ(kHomepageRlzString, UTF16ToUTF8(rlz).c_str()); |
596 | 618 |
597 // Make sure cache is valid. | 619 // Make sure cache is valid. |
598 tracker_.set_assume_not_ui_thread(false); | 620 tracker_.set_assume_not_ui_thread(false); |
599 | 621 |
600 EXPECT_TRUE(RLZTracker::GetAccessPointRlz(rlz_lib::CHROME_OMNIBOX, &rlz)); | 622 EXPECT_TRUE(RLZTracker::GetAccessPointRlz(RLZTracker::CHROME_OMNIBOX, &rlz)); |
601 EXPECT_STREQ(kOmniboxRlzString, UTF16ToUTF8(rlz).c_str()); | 623 EXPECT_STREQ(kOmniboxRlzString, UTF16ToUTF8(rlz).c_str()); |
602 EXPECT_TRUE(RLZTracker::GetAccessPointRlz(rlz_lib::CHROME_HOME_PAGE, &rlz)); | 624 EXPECT_TRUE(RLZTracker::GetAccessPointRlz( |
| 625 RLZTracker::CHROME_HOME_PAGE, &rlz)); |
603 EXPECT_STREQ(kHomepageRlzString, UTF16ToUTF8(rlz).c_str()); | 626 EXPECT_STREQ(kHomepageRlzString, UTF16ToUTF8(rlz).c_str()); |
604 | 627 |
605 // Perform ping. | 628 // Perform ping. |
606 tracker_.set_assume_not_ui_thread(true); | 629 tracker_.set_assume_not_ui_thread(true); |
607 RLZTracker::InitRlzDelayed(true, 20, true, true); | 630 RLZTracker::InitRlzDelayed(true, 20, true, true); |
608 InvokeDelayedInit(); | 631 InvokeDelayedInit(); |
609 ExpectRlzPingSent(true); | 632 ExpectRlzPingSent(true); |
610 | 633 |
611 // Make sure cache is now updated. | 634 // Make sure cache is now updated. |
612 tracker_.set_assume_not_ui_thread(false); | 635 tracker_.set_assume_not_ui_thread(false); |
613 | 636 |
614 EXPECT_TRUE(RLZTracker::GetAccessPointRlz(rlz_lib::CHROME_OMNIBOX, &rlz)); | 637 EXPECT_TRUE(RLZTracker::GetAccessPointRlz(RLZTracker::CHROME_OMNIBOX, &rlz)); |
615 EXPECT_STREQ(kNewOmniboxRlzString, UTF16ToUTF8(rlz).c_str()); | 638 EXPECT_STREQ(kNewOmniboxRlzString, UTF16ToUTF8(rlz).c_str()); |
616 EXPECT_TRUE(RLZTracker::GetAccessPointRlz(rlz_lib::CHROME_HOME_PAGE, &rlz)); | 639 EXPECT_TRUE(RLZTracker::GetAccessPointRlz( |
| 640 RLZTracker::CHROME_HOME_PAGE, &rlz)); |
617 EXPECT_STREQ(kNewHomepageRlzString, UTF16ToUTF8(rlz).c_str()); | 641 EXPECT_STREQ(kNewHomepageRlzString, UTF16ToUTF8(rlz).c_str()); |
618 } | 642 } |
619 | 643 |
620 TEST_F(RlzLibTest, ObserveHandlesBadArgs) { | 644 TEST_F(RlzLibTest, ObserveHandlesBadArgs) { |
621 scoped_ptr<NavigationEntry> entry(NavigationEntry::Create()); | 645 scoped_ptr<NavigationEntry> entry(NavigationEntry::Create()); |
622 entry->SetPageID(0); | 646 entry->SetPageID(0); |
623 entry->SetTransitionType(content::PAGE_TRANSITION_LINK); | 647 entry->SetTransitionType(content::PAGE_TRANSITION_LINK); |
624 tracker_.Observe(content::NOTIFICATION_NAV_ENTRY_PENDING, | 648 tracker_.Observe(content::NOTIFICATION_NAV_ENTRY_PENDING, |
625 content::NotificationService::AllSources(), | 649 content::NotificationService::AllSources(), |
626 content::Details<NavigationEntry>(NULL)); | 650 content::Details<NavigationEntry>(NULL)); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
667 SetMainBrand("GGLS"); | 691 SetMainBrand("GGLS"); |
668 SetReactivationBrand("GGRS"); | 692 SetReactivationBrand("GGRS"); |
669 | 693 |
670 RLZTracker::InitRlzDelayed(true, 20, true, true); | 694 RLZTracker::InitRlzDelayed(true, 20, true, true); |
671 InvokeDelayedInit(); | 695 InvokeDelayedInit(); |
672 | 696 |
673 ExpectRlzPingSent(false); | 697 ExpectRlzPingSent(false); |
674 ExpectReactivationRlzPingSent(false); | 698 ExpectReactivationRlzPingSent(false); |
675 } | 699 } |
676 #endif // defined(OS_WIN) | 700 #endif // defined(OS_WIN) |
OLD | NEW |