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 <vector> | 5 #include <vector> |
6 | 6 |
7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
10 #include "base/time.h" | 10 #include "base/time.h" |
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 1357566075, // unix epoch for 7 Jan 2013 5:40:75 PST. | 449 1357566075, // unix epoch for 7 Jan 2013 5:40:75 PST. |
450 1000, 200, 100, 3600, 400, 30, false); | 450 1000, 200, 100, 3600, 400, 30, false); |
451 #else | 451 #else |
452 promo_test.Init( | 452 promo_test.Init( |
453 "{" | 453 "{" |
454 " \"mobile_ntp_sync_promo\": [" | 454 " \"mobile_ntp_sync_promo\": [" |
455 " {" | 455 " {" |
456 " \"date\":" | 456 " \"date\":" |
457 " [" | 457 " [" |
458 " {" | 458 " {" |
459 " \"start\":\"15 Jan 2012 10:50:85 PST\"," | 459 " \"start\":\"3 Aug 1999 9:26:06 GMT\"," |
460 " \"end\":\"7 Jan 2013 5:40:75 PST\"" | 460 " \"end\":\"7 Jan 2013 5:40:75 PST\"" |
461 " }" | 461 " }" |
462 " ]," | 462 " ]," |
463 " \"strings\":" | 463 " \"strings\":" |
464 " {" | 464 " {" |
465 " \"MOBILE_PROMO_CHROME_SHORT_TEXT\":" | 465 " \"MOBILE_PROMO_CHROME_SHORT_TEXT\":" |
466 " \"Like Chrome? Go http://www.google.com/chrome/\"," | 466 " \"Like Chrome? Go http://www.google.com/chrome/\"," |
467 " \"MOBILE_PROMO_CHROME_LONG_TEXT\":" | 467 " \"MOBILE_PROMO_CHROME_LONG_TEXT\":" |
468 " \"It\'s simple. Go http://www.google.com/chrome/\"," | 468 " \"It\'s simple. Go http://www.google.com/chrome/\"," |
469 " \"MOBILE_PROMO_EMAIL_BODY\":\"This is the body.\"," | 469 " \"MOBILE_PROMO_EMAIL_BODY\":\"This is the body.\"," |
(...skipping 19 matching lines...) Expand all Loading... |
489 " \"promo_action_args\":[\"MOBILE_PROMO_EMAIL_BODY\",\"XXX\"]," | 489 " \"promo_action_args\":[\"MOBILE_PROMO_EMAIL_BODY\",\"XXX\"]," |
490 " \"XXX\":\"XXX_VALUE\"" | 490 " \"XXX\":\"XXX_VALUE\"" |
491 " }," | 491 " }," |
492 " \"max_views\":30" | 492 " \"max_views\":30" |
493 " }" | 493 " }" |
494 " ]" | 494 " ]" |
495 "}", | 495 "}", |
496 "Like Chrome? Go http://www.google.com/chrome/", | 496 "Like Chrome? Go http://www.google.com/chrome/", |
497 "It\'s simple. Go http://www.google.com/chrome/", | 497 "It\'s simple. Go http://www.google.com/chrome/", |
498 "ACTION_EMAIL", "This is the body.", "XXX value", | 498 "ACTION_EMAIL", "This is the body.", "XXX value", |
499 1326653485, // unix epoch for 15 Jan 2012 10:50:85 PST. | 499 // We hardcode the unix epoch time to make sure our parsing works. |
500 1357566075, // unix epoch for 7 Jan 2013 5:40:75 PST. | 500 // The starting date is in 1999 to make tests pass on Android devices |
| 501 // with incorrect or unset date/time. |
| 502 933672366, // unix epoch for 3 Aug 1999 9:26:06 GMT. |
| 503 1357566075, // unix epoch for 7 Jan 2013 5:40:75 PST. |
501 1000, 200, 100, 3600, 400, 30, false); | 504 1000, 200, 100, 3600, 400, 30, false); |
502 #endif // !defined(OS_ANDROID) | 505 #endif // !defined(OS_ANDROID) |
503 | 506 |
504 promo_test.InitPromoFromJson(true); | 507 promo_test.InitPromoFromJson(true); |
505 | 508 |
506 // Second time should not trigger a notification. | 509 // Second time should not trigger a notification. |
507 promo_test.InitPromoFromJson(false); | 510 promo_test.InitPromoFromJson(false); |
508 | 511 |
509 promo_test.TestInitFromPrefs(); | 512 promo_test.TestInitFromPrefs(); |
510 | 513 |
511 // Test various conditions of CanShow. | 514 // Test various conditions of CanShow. |
512 // TestGroup Has the side effect of setting us to a passing group. | 515 // TestGroup Has the side effect of setting us to a passing group. |
513 promo_test.TestGroup(); | 516 promo_test.TestGroup(); |
514 promo_test.TestViews(); | 517 promo_test.TestViews(); |
515 promo_test.TestClosed(); | 518 promo_test.TestClosed(); |
516 promo_test.TestPromoText(); | 519 promo_test.TestPromoText(); |
517 promo_test.TestTime(); | 520 promo_test.TestTime(); |
518 promo_test.TestIncrement(); | 521 promo_test.TestIncrement(); |
519 promo_test.TestGplus(); | 522 promo_test.TestGplus(); |
520 } | 523 } |
521 | 524 |
522 TEST_F(PromoResourceServiceTest, PromoServerURLTest) { | 525 TEST_F(PromoResourceServiceTest, PromoServerURLTest) { |
523 GURL promo_server_url = NotificationPromo::PromoServerURL(); | 526 GURL promo_server_url = NotificationPromo::PromoServerURL(); |
524 EXPECT_FALSE(promo_server_url.is_empty()); | 527 EXPECT_FALSE(promo_server_url.is_empty()); |
525 EXPECT_TRUE(promo_server_url.SchemeIs("https")); | 528 EXPECT_TRUE(promo_server_url.SchemeIs("https")); |
526 // TODO(achuith): Test this better. | 529 // TODO(achuith): Test this better. |
527 } | 530 } |
OLD | NEW |