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

Unified Diff: chrome/browser/android/webapps/add_to_homescreen_data_fetcher_unittest.cc

Issue 2362813003: Make it clear that AddToHomescreenDataFetcher ignores WebApplicationInfo for WebAPK compatible pages (Closed)
Patch Set: Created 4 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
Index: chrome/browser/android/webapps/add_to_homescreen_data_fetcher_unittest.cc
diff --git a/chrome/browser/android/webapps/add_to_homescreen_data_fetcher_unittest.cc b/chrome/browser/android/webapps/add_to_homescreen_data_fetcher_unittest.cc
index c89758fce24918098e8e65351d8efcd8b5c4f670..6c902265717cd7e9877337581f1128a210a50b49 100644
--- a/chrome/browser/android/webapps/add_to_homescreen_data_fetcher_unittest.cc
+++ b/chrome/browser/android/webapps/add_to_homescreen_data_fetcher_unittest.cc
@@ -14,6 +14,7 @@
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "base/strings/nullable_string16.h"
+#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/time/time.h"
#include "chrome/common/web_application_info.h"
@@ -269,6 +270,59 @@ class AddToHomescreenDataFetcherTestCommon
DISALLOW_COPY_AND_ASSIGN(AddToHomescreenDataFetcherTestCommon);
};
+// Test that when the manifest provides Manifest::short_name but not
+// Manifest::name that Manifest::short_name is used as the name instead of
+// WebApplicationInfo::title.
+TEST_P(AddToHomescreenDataFetcherTestCommon,
+ ManifestShortNameClobbersWebApplicationName) {
+ WebApplicationInfo web_application_info;
+ web_application_info.title = base::UTF8ToUTF16("Meta Title");
+
+ content::Manifest manifest(BuildDefaultManifest());
+ manifest.name = base::NullableString16();
+
+ RegisterServiceWorker(GURL(kDefaultStartUrl));
+ SetManifest(GURL(kDefaultManifestUrl), manifest, 0);
+
+ ObserverWaiter waiter;
+ scoped_refptr<AddToHomescreenDataFetcher> fetcher(BuildFetcher(&waiter));
+ fetcher->OnDidGetWebApplicationInfo(web_application_info);
Xi Han 2016/09/26 17:48:12 Once when a fetcher is created by BuildFetcher(),
pkotwicz 2016/09/26 20:13:47 Tests with use TestWebContents do not create rende
Xi Han 2016/09/26 20:15:41 Acknowledged.
+ waiter.WaitForDataAvailable();
+
+ EXPECT_TRUE(base::EqualsASCII(fetcher->shortcut_info().name,
+ kDefaultManifestShortName));
+
+ fetcher->set_weak_observer(nullptr);
+}
+
+// Test that when the manifest does not provide either Manifest::short_name nor
+// Manifest::name that:
+// - The page is not WebAPK compatible.
+// - WebApplicationInfo::title is used as the "name".
+TEST_P(AddToHomescreenDataFetcherTestCommon, ManifestNoNameNoShortName) {
+ const char* kWebApplicationInfoTitle = "Meta Title";
+ WebApplicationInfo web_application_info;
+ web_application_info.title = base::UTF8ToUTF16(kWebApplicationInfoTitle);
+
+ content::Manifest manifest(BuildDefaultManifest());
+ manifest.name = base::NullableString16();
+ manifest.short_name = base::NullableString16();
+
+ RegisterServiceWorker(GURL(kDefaultStartUrl));
+ SetManifest(GURL(kDefaultManifestUrl), manifest, 0);
+
+ ObserverWaiter waiter;
+ scoped_refptr<AddToHomescreenDataFetcher> fetcher(BuildFetcher(&waiter));
+ fetcher->OnDidGetWebApplicationInfo(web_application_info);
+ waiter.WaitForDataAvailable();
+
+ EXPECT_FALSE(waiter.is_webapk_compatible);
+ EXPECT_TRUE(base::EqualsASCII(fetcher->shortcut_info().name,
+ kWebApplicationInfoTitle));
+
+ fetcher->set_weak_observer(nullptr);
+}
+
// Checks that the AddToHomescreenDataFetcher::Observer callbacks are called
// when a service worker is registered and the manifest fetch times out.
TEST_P(AddToHomescreenDataFetcherTestCommon, ManifestFetchTimesOut) {

Powered by Google App Engine
This is Rietveld 408576698