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

Unified Diff: chrome/browser/android/webapk/webapk_installer_unittest.cc

Issue 2515293004: Chrome talks to Play to install WebAPKs. (Closed)
Patch Set: Make GooglePlayWebApkInstallDelegate as a singleton. Created 4 years 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/android/webapk/webapk_installer.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/android/webapk/webapk_installer_unittest.cc
diff --git a/chrome/browser/android/webapk/webapk_installer_unittest.cc b/chrome/browser/android/webapk/webapk_installer_unittest.cc
index 10021ff93107a0b7e7a694291742e2e107c0910b..0734459e9e6c4e76a8bf1dd1f2427afed6999d6c 100644
--- a/chrome/browser/android/webapk/webapk_installer_unittest.cc
+++ b/chrome/browser/android/webapk/webapk_installer_unittest.cc
@@ -52,12 +52,17 @@ const char* kDownloadedWebApkPackageName = "party.unicode";
// WebApkInstaller subclass where
// WebApkInstaller::StartInstallingDownloadedWebApk() and
-// WebApkInstaller::StartUpdateUsingDownloadedWebApk() are stubbed out.
+// WebApkInstaller::StartUpdateUsingDownloadedWebApk() and
+// WebApkInstaller::HasGooglePlayWebApkInstallDelegate() and
+// WebApkInstaller::InstallOrUpdateWebApkFromGooglePlay() are stubbed out.
class TestWebApkInstaller : public WebApkInstaller {
public:
TestWebApkInstaller(const ShortcutInfo& shortcut_info,
- const SkBitmap& shortcut_icon)
- : WebApkInstaller(shortcut_info, shortcut_icon) {}
+ const SkBitmap& shortcut_icon,
+ bool has_google_play_webapk_install_delegate)
+ : WebApkInstaller(shortcut_info, shortcut_icon),
+ has_google_play_webapk_install_delegate_(
+ has_google_play_webapk_install_delegate) {}
bool StartInstallingDownloadedWebApk(
JNIEnv* env,
@@ -73,6 +78,17 @@ class TestWebApkInstaller : public WebApkInstaller {
return true;
}
+ bool HasGooglePlayWebApkInstallDelegate() override {
+ return has_google_play_webapk_install_delegate_;
+ }
+
+ bool InstallOrUpdateWebApkFromGooglePlay(const std::string& package_name,
+ int version,
+ const std::string& token) override {
+ PostTaskToRunSuccessCallback();
+ return true;
+ }
+
void PostTaskToRunSuccessCallback() {
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE,
@@ -80,6 +96,9 @@ class TestWebApkInstaller : public WebApkInstaller {
}
private:
+ // Whether the Google Play install delegate is available.
+ bool has_google_play_webapk_install_delegate_;
+
DISALLOW_COPY_AND_ASSIGN(TestWebApkInstaller);
};
@@ -89,9 +108,15 @@ class WebApkInstallerRunner {
explicit WebApkInstallerRunner(const GURL& best_icon_url)
: url_request_context_getter_(new net::TestURLRequestContextGetter(
base::ThreadTaskRunnerHandle::Get())),
- best_icon_url_(best_icon_url) {}
+ best_icon_url_(best_icon_url),
+ has_google_play_webapk_install_delegate_(false) {}
+
~WebApkInstallerRunner() {}
+ void SetHasGooglePlayWebApkInstallDelegate(bool has_delegate) {
+ has_google_play_webapk_install_delegate_ = has_delegate;
+ }
+
void RunInstallWebApk() {
WebApkInstaller* installer = CreateWebApkInstaller();
@@ -123,7 +148,8 @@ class WebApkInstallerRunner {
info.best_icon_url = best_icon_url_;
// WebApkInstaller owns itself.
- WebApkInstaller* installer = new TestWebApkInstaller(info, SkBitmap());
+ WebApkInstaller* installer = new TestWebApkInstaller(
+ info, SkBitmap(), has_google_play_webapk_install_delegate_);
installer->SetTimeoutMs(100);
return installer;
}
@@ -154,6 +180,9 @@ class WebApkInstallerRunner {
// Whether the installation process succeeded.
bool success_;
+ // Whether the Google Play install delegate is available.
+ bool has_google_play_webapk_install_delegate_;
+
DISALLOW_COPY_AND_ASSIGN(WebApkInstallerRunner);
};
@@ -331,3 +360,11 @@ TEST_F(WebApkInstallerTest, UpdateSuccess) {
runner->RunUpdateWebApk();
EXPECT_TRUE(runner->success());
}
+
+// Test installation succeeds using Google Play.
+TEST_F(WebApkInstallerTest, InstallFromGooglePlaySuccess) {
+ std::unique_ptr<WebApkInstallerRunner> runner = CreateWebApkInstallerRunner();
+ runner->SetHasGooglePlayWebApkInstallDelegate(true);
+ runner->RunInstallWebApk();
+ EXPECT_TRUE(runner->success());
+}
« no previous file with comments | « chrome/browser/android/webapk/webapk_installer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698