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

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

Issue 2937823002: [Android] Make WebApplicationInfo and Web Manifest mutually exclusive (Closed)
Patch Set: Merge branch 'master' into reenable_tests000 Created 3 years, 6 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 8725d7ff0162e89ecb6ed5bb2fccaef94acc377a..a0106ec111aeceb60c4e0dfa01e0e0843336f283 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
@@ -267,6 +267,33 @@ TEST_F(AddToHomescreenDataFetcherTest,
fetcher->set_weak_observer(nullptr);
}
+// Test that a page with WebApplicationInfo but no Web Manifest is not WebAPK
+// capable.
+TEST_F(AddToHomescreenDataFetcherTest, WebApplicationInfoNotWebApkCompatible) {
+ const char* kWebApplicationInfoTitle = "Meta Title";
+ WebApplicationInfo web_application_info;
+ web_application_info.title = base::UTF8ToUTF16(kWebApplicationInfoTitle);
+ web_application_info.mobile_capable = WebApplicationInfo::MOBILE_CAPABLE;
+
+ RegisterServiceWorker(GURL(kDefaultStartUrl));
+ SetManifest(GURL(), content::Manifest(), 0);
+
+ ObserverWaiter waiter;
+ scoped_refptr<AddToHomescreenDataFetcher> fetcher(
+ BuildFetcher(true, &waiter));
+ fetcher->OnDidGetWebApplicationInfo(web_application_info);
+ waiter.WaitForDataAvailable();
+
+ EXPECT_TRUE(waiter.determined_webapk_compatibility());
+ EXPECT_FALSE(waiter.is_webapk_compatible());
+
+ EXPECT_TRUE(base::EqualsASCII(fetcher->shortcut_info().name,
+ kWebApplicationInfoTitle));
+ EXPECT_EQ(blink::kWebDisplayModeStandalone, fetcher->shortcut_info().display);
+
+ fetcher->set_weak_observer(nullptr);
+}
+
// Class for tests which should be run with AddToHomescreenDataFetcher built
// with both true and false values of |check_webapk_compatible|.
class AddToHomescreenDataFetcherTestCommon
@@ -315,32 +342,33 @@ TEST_P(AddToHomescreenDataFetcherTestCommon,
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);
+// Test that when a manifest is provided that it overwrites the
+// WebapplicationInfo.
+TEST_P(AddToHomescreenDataFetcherTestCommon,
+ ManifestOverwritesWebApplicationInfo) {
+ 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();
+ content::Manifest manifest(BuildDefaultManifest());
+ manifest.name = base::NullableString16();
+ manifest.short_name = base::NullableString16();
- RegisterServiceWorker(GURL(kDefaultStartUrl));
- SetManifest(GURL(kDefaultManifestUrl), manifest, 0);
+ RegisterServiceWorker(GURL(kDefaultStartUrl));
+ SetManifest(GURL(kDefaultManifestUrl), manifest, 0);
- ObserverWaiter waiter;
- scoped_refptr<AddToHomescreenDataFetcher> fetcher(BuildFetcher(&waiter));
- fetcher->OnDidGetWebApplicationInfo(web_application_info);
- waiter.WaitForDataAvailable();
+ 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));
+ // The name should be empty (even though one is provided in
+ // WebApplicationInfo) because the name was not provided in the Web
+ // Manifest.
+ EXPECT_TRUE(fetcher->shortcut_info().name.empty());
+ EXPECT_EQ(blink::kWebDisplayModeUndefined, fetcher->shortcut_info().display);
- fetcher->set_weak_observer(nullptr);
+ fetcher->set_weak_observer(nullptr);
}
// Checks that the AddToHomescreenDataFetcher::Observer callbacks are called

Powered by Google App Engine
This is Rietveld 408576698