Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1796)

Unified Diff: chrome/browser/extensions/apps_promo_unittest.cc

Issue 7820003: Add support to download web store promo logos over https. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix sync failures Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/extensions/apps_promo.cc ('k') | chrome/browser/ui/webui/ntp/app_launcher_handler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/apps_promo_unittest.cc
diff --git a/chrome/browser/extensions/apps_promo_unittest.cc b/chrome/browser/extensions/apps_promo_unittest.cc
index 607da43b01086ab9b6552b488d0cdf2565235e4e..77d40ea02fccc80d5b7d6432f84d679e427ded6e 100644
--- a/chrome/browser/extensions/apps_promo_unittest.cc
+++ b/chrome/browser/extensions/apps_promo_unittest.cc
@@ -108,9 +108,10 @@ TEST_F(ExtensionAppsPromo, HappyPath) {
&promo_just_expired));
// Once the promo is set, we show both the promo and app launcher.
- AppsPromo::SetPromo(kPromoId, kPromoHeader, kPromoButton,
- GURL(kPromoLink), kPromoExpire, GURL(""),
- kPromoUserGroup);
+ AppsPromo::PromoData promo_data(kPromoId, kPromoHeader, kPromoButton,
+ GURL(kPromoLink), kPromoExpire, GURL(""),
+ kPromoUserGroup);
+ AppsPromo::SetPromo(promo_data);
AppsPromo::SetWebStoreSupportedForLocale(true);
EXPECT_TRUE(AppsPromo::IsPromoSupportedForLocale());
EXPECT_TRUE(apps_promo()->ShouldShowAppLauncher(installed_ids));
@@ -148,60 +149,56 @@ TEST_F(ExtensionAppsPromo, HappyPath) {
// Tests get and set of promo content.
TEST_F(ExtensionAppsPromo, PromoPrefs) {
// Store a promo....
- AppsPromo::SetPromo(kPromoId, kPromoHeader, kPromoButton,
- GURL(kPromoLink), kPromoExpire, GURL(""),
- kPromoUserGroup);
+ AppsPromo::PromoData promo_data(kPromoId, kPromoHeader, kPromoButton,
+ GURL(kPromoLink), kPromoExpire, GURL(""),
+ kPromoUserGroup);
+ AppsPromo::SetPromo(promo_data);
// ... then make sure AppsPromo can access it.
- EXPECT_EQ(kPromoId, AppsPromo::GetPromoId());
- EXPECT_EQ(kPromoHeader, AppsPromo::GetPromoHeaderText());
- EXPECT_EQ(kPromoButton, AppsPromo::GetPromoButtonText());
- EXPECT_EQ(GURL(kPromoLink), AppsPromo::GetPromoLink());
- EXPECT_EQ(kPromoExpire, AppsPromo::GetPromoExpireText());
- EXPECT_EQ(kPromoUserGroup, AppsPromo::GetPromoUserGroup());
+ AppsPromo::PromoData actual_data = AppsPromo::GetPromo();
+ EXPECT_EQ(kPromoId, actual_data.id);
+ EXPECT_EQ(kPromoHeader, actual_data.header);
+ EXPECT_EQ(kPromoButton, actual_data.button);
+ EXPECT_EQ(GURL(kPromoLink), actual_data.link);
+ EXPECT_EQ(kPromoExpire, actual_data.expire);
+ EXPECT_EQ(kPromoUserGroup, actual_data.user_group);
// The promo logo should be the default value.
- EXPECT_EQ(GURL(kPromoLogo), AppsPromo::GetPromoLogo());
+ EXPECT_EQ(GURL(kPromoLogo), actual_data.logo);
EXPECT_TRUE(AppsPromo::IsPromoSupportedForLocale());
AppsPromo::ClearPromo();
- EXPECT_EQ("", AppsPromo::GetPromoId());
- EXPECT_EQ("", AppsPromo::GetPromoHeaderText());
- EXPECT_EQ("", AppsPromo::GetPromoButtonText());
- EXPECT_EQ(GURL(""), AppsPromo::GetPromoLink());
- EXPECT_EQ("", AppsPromo::GetPromoExpireText());
- EXPECT_EQ(AppsPromo::USERS_NONE, AppsPromo::GetPromoUserGroup());
- EXPECT_EQ(GURL(kPromoLogo), AppsPromo::GetPromoLogo());
+ actual_data = AppsPromo::GetPromo();
+ EXPECT_EQ("", actual_data.id);
+ EXPECT_EQ("", actual_data.header);
+ EXPECT_EQ("", actual_data.button);
+ EXPECT_EQ(GURL(""), actual_data.link);
+ EXPECT_EQ("", actual_data.expire);
+ EXPECT_EQ(AppsPromo::USERS_NONE, actual_data.user_group);
+ EXPECT_EQ(GURL(kPromoLogo), actual_data.logo);
EXPECT_FALSE(AppsPromo::IsPromoSupportedForLocale());
// Make sure we can set the logo to something other than the default.
std::string promo_logo = "data:image/png;base64,iVBORw0kGgoAAAN";
- AppsPromo::SetPromo(kPromoId, kPromoHeader, kPromoButton,
- GURL(kPromoLink), kPromoExpire, GURL(promo_logo),
- kPromoUserGroup);
- EXPECT_EQ(GURL(promo_logo), AppsPromo::GetPromoLogo());
+ promo_data.logo = GURL(promo_logo);
+ AppsPromo::SetPromo(promo_data);
+ EXPECT_EQ(GURL(promo_logo), AppsPromo::GetPromo().logo);
EXPECT_TRUE(AppsPromo::IsPromoSupportedForLocale());
- // Verify that the default is returned instead of http or https URLs.
- promo_logo = "http://google.com/logo.png";
- AppsPromo::SetPromo(kPromoId, kPromoHeader, kPromoButton,
- GURL(kPromoLink), kPromoExpire, GURL(promo_logo),
- kPromoUserGroup);
- EXPECT_EQ(GURL(kPromoLogo), AppsPromo::GetPromoLogo());
+ // Verify that the default is returned instead of HTTP or HTTPS URLs.
+ promo_data.logo = GURL("http://google.com/logo.png");
+ AppsPromo::SetPromo(promo_data);
+ EXPECT_EQ(GURL(kPromoLogo), AppsPromo::GetPromo().logo);
EXPECT_TRUE(AppsPromo::IsPromoSupportedForLocale());
- promo_logo = "https://google.com/logo.png";
- AppsPromo::SetPromo(kPromoId, kPromoHeader, kPromoButton,
- GURL(kPromoLink), kPromoExpire, GURL(promo_logo),
- kPromoUserGroup);
- EXPECT_EQ(GURL(kPromoLogo), AppsPromo::GetPromoLogo());
+ promo_data.logo = GURL("https://google.com/logo.png");
+ AppsPromo::SetPromo(promo_data);
+ EXPECT_EQ(GURL(kPromoLogo), AppsPromo::GetPromo().logo);
EXPECT_TRUE(AppsPromo::IsPromoSupportedForLocale());
// Try an invalid URL.
- promo_logo = "sldkfjlsdn";
- AppsPromo::SetPromo(kPromoId, kPromoHeader, kPromoButton,
- GURL(kPromoLink), kPromoExpire, GURL(promo_logo),
- kPromoUserGroup);
- EXPECT_EQ(GURL(kPromoLogo), AppsPromo::GetPromoLogo());
+ promo_data.logo = GURL("sldkfjlsdn");
+ AppsPromo::SetPromo(promo_data);
+ EXPECT_EQ(GURL(kPromoLogo), AppsPromo::GetPromo().logo);
EXPECT_TRUE(AppsPromo::IsPromoSupportedForLocale());
// Try the web store supported flag.
@@ -210,6 +207,11 @@ TEST_F(ExtensionAppsPromo, PromoPrefs) {
EXPECT_TRUE(AppsPromo::IsWebStoreSupportedForLocale());
AppsPromo::SetWebStoreSupportedForLocale(false);
EXPECT_FALSE(AppsPromo::IsWebStoreSupportedForLocale());
+
+ // Try setting and getting the source logo URL.
+ GURL expected_source("https://www.google.com/images/test.png");
+ AppsPromo::SetSourcePromoLogoURL(expected_source);
+ EXPECT_EQ(expected_source, AppsPromo::GetSourcePromoLogoURL());
}
// Tests maximizing the promo for USERS_NONE.
@@ -218,16 +220,16 @@ TEST_F(ExtensionAppsPromo, UpdatePromoFocus_UsersNone) {
ExpectAppsSectionMaximized(prefs(), false);
// The promo shouldn't maximize for anyone.
- AppsPromo::SetPromo(kPromoId, kPromoHeader, kPromoButton,
- GURL(kPromoLink), kPromoExpire, GURL(""),
- AppsPromo::USERS_NONE);
+ AppsPromo::PromoData promo_data(kPromoId, kPromoHeader, kPromoButton,
+ GURL(kPromoLink), kPromoExpire, GURL(""),
+ AppsPromo::USERS_NONE);
+ AppsPromo::SetPromo(promo_data);
apps_promo()->MaximizeAppsIfNecessary();
ExpectAppsSectionMaximized(prefs(), false);
// The promo still shouldn't maximize if we change it's ID.
- AppsPromo::SetPromo("lkksdf", kPromoHeader, kPromoButton,
- GURL(kPromoLink), kPromoExpire, GURL(""),
- AppsPromo::USERS_NONE);
+ promo_data.id = "lkksdf";
+ AppsPromo::SetPromo(promo_data);
apps_promo()->MaximizeAppsIfNecessary();
ExpectAppsSectionMaximized(prefs(), false);
}
@@ -238,19 +240,17 @@ TEST_F(ExtensionAppsPromo, UpdatePromoFocus_UsersExisting) {
ExpectAppsSectionMaximized(prefs(), false);
// Set the promo content.
- AppsPromo::SetPromo(kPromoId, kPromoHeader, kPromoButton,
- GURL(kPromoLink), kPromoExpire, GURL(""),
- AppsPromo::USERS_EXISTING);
-
+ AppsPromo::PromoData promo_data(kPromoId, kPromoHeader, kPromoButton,
+ GURL(kPromoLink), kPromoExpire, GURL(""),
+ AppsPromo::USERS_EXISTING);
+ AppsPromo::SetPromo(promo_data);
// This is a new user so the apps section shouldn't maximize.
apps_promo()->MaximizeAppsIfNecessary();
ExpectAppsSectionMaximized(prefs(), false);
-
// Set a new promo and now it should maximize.
- AppsPromo::SetPromo("lksdf", kPromoHeader, kPromoButton,
- GURL(kPromoLink), kPromoExpire, GURL(""),
- AppsPromo::USERS_EXISTING);
+ promo_data.id = "lksdf";
+ AppsPromo::SetPromo(promo_data);
apps_promo()->MaximizeAppsIfNecessary();
ExpectAppsSectionMaximized(prefs(), true);
@@ -265,9 +265,10 @@ TEST_F(ExtensionAppsPromo, UpdatePromoFocus_UsersNew) {
ExpectAppsSectionMaximized(prefs(), false);
// The promo should maximize for new users.
- AppsPromo::SetPromo(kPromoId, kPromoHeader, kPromoButton,
- GURL(kPromoLink), kPromoExpire, GURL(""),
- AppsPromo::USERS_NEW);
+ AppsPromo::PromoData promo_data(kPromoId, kPromoHeader, kPromoButton,
+ GURL(kPromoLink), kPromoExpire, GURL(""),
+ AppsPromo::USERS_NEW);
+ AppsPromo::SetPromo(promo_data);
apps_promo()->MaximizeAppsIfNecessary();
ExpectAppsSectionMaximized(prefs(), true);
@@ -280,9 +281,8 @@ TEST_F(ExtensionAppsPromo, UpdatePromoFocus_UsersNew) {
ExpectAppsSectionMaximized(prefs(), false);
// Another promo targetting new users should not maximize.
- AppsPromo::SetPromo("lksdf", kPromoHeader, kPromoButton,
- GURL(kPromoLink), kPromoExpire, GURL(""),
- AppsPromo::USERS_NEW);
+ promo_data.id = "lksdf";
+ AppsPromo::SetPromo(promo_data);
apps_promo()->MaximizeAppsIfNecessary();
ExpectAppsSectionMaximized(prefs(), false);
}
@@ -293,9 +293,10 @@ TEST_F(ExtensionAppsPromo, UpdatePromoFocus_UsersAll) {
ExpectAppsSectionMaximized(prefs(), false);
// The apps section should maximize for all users.
- AppsPromo::SetPromo(kPromoId, kPromoHeader, kPromoButton,
- GURL(kPromoLink), kPromoExpire, GURL(""),
- AppsPromo::USERS_NEW | AppsPromo::USERS_EXISTING);
+ AppsPromo::PromoData promo_data(
+ kPromoId, kPromoHeader, kPromoButton, GURL(kPromoLink), kPromoExpire,
+ GURL(""), AppsPromo::USERS_NEW | AppsPromo::USERS_EXISTING);
+ AppsPromo::SetPromo(promo_data);
apps_promo()->MaximizeAppsIfNecessary();
ExpectAppsSectionMaximized(prefs(), true);
@@ -307,9 +308,8 @@ TEST_F(ExtensionAppsPromo, UpdatePromoFocus_UsersAll) {
ExpectAppsSectionMaximized(prefs(), false);
// A promo with a new ID should maximize though.
- AppsPromo::SetPromo("lkksdf", kPromoHeader, kPromoButton,
- GURL(kPromoLink), kPromoExpire, GURL(""),
- AppsPromo::USERS_NEW | AppsPromo::USERS_EXISTING);
+ promo_data.id = "lkksdf";
+ AppsPromo::SetPromo(promo_data);
apps_promo()->MaximizeAppsIfNecessary();
ExpectAppsSectionMaximized(prefs(), true);
}
@@ -320,9 +320,10 @@ TEST_F(ExtensionAppsPromo, PromoHiddenByPref) {
// When the "hide" pref is false, the promo should still appear.
prefs()->SetBoolean(prefs::kNTPHideWebStorePromo, false);
- AppsPromo::SetPromo(kPromoId, kPromoHeader, kPromoButton,
- GURL(kPromoLink), kPromoExpire, GURL(""),
- AppsPromo::USERS_NEW | AppsPromo::USERS_EXISTING);
+ AppsPromo::PromoData promo_data(
+ kPromoId, kPromoHeader, kPromoButton, GURL(kPromoLink), kPromoExpire,
+ GURL(""), AppsPromo::USERS_NEW | AppsPromo::USERS_EXISTING);
+ AppsPromo::SetPromo(promo_data);
bool just_expired;
bool show_promo = apps_promo()->ShouldShowPromo(
apps_promo()->old_default_apps(), &just_expired);
« no previous file with comments | « chrome/browser/extensions/apps_promo.cc ('k') | chrome/browser/ui/webui/ntp/app_launcher_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698