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

Side by Side Diff: chrome/browser/android/webapk/webapk_installer_unittest.cc

Issue 2515293004: Chrome talks to Play to install WebAPKs. (Closed)
Patch Set: Don't use play install in webapk_installer_unittest. 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "chrome/browser/android/webapk/webapk_installer.h" 5 #include "chrome/browser/android/webapk/webapk_installer.h"
6 6
7 #include <jni.h> 7 #include <jni.h>
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 10
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 45
46 // URL of file to download from the WebAPK server. We use a random file in the 46 // URL of file to download from the WebAPK server. We use a random file in the
47 // test data directory. 47 // test data directory.
48 const char* kDownloadUrl = "/simple.html"; 48 const char* kDownloadUrl = "/simple.html";
49 49
50 // The package name of the downloaded WebAPK. 50 // The package name of the downloaded WebAPK.
51 const char* kDownloadedWebApkPackageName = "party.unicode"; 51 const char* kDownloadedWebApkPackageName = "party.unicode";
52 52
53 // WebApkInstaller subclass where 53 // WebApkInstaller subclass where
54 // WebApkInstaller::StartInstallingDownloadedWebApk() and 54 // WebApkInstaller::StartInstallingDownloadedWebApk() and
55 // WebApkInstaller::StartUpdateUsingDownloadedWebApk() are stubbed out. 55 // WebApkInstaller::StartUpdateUsingDownloadedWebApk() and
56 // WebApkInstaller::HasGooglePlayWebApkInstallDelegate() are stubbed out.
56 class TestWebApkInstaller : public WebApkInstaller { 57 class TestWebApkInstaller : public WebApkInstaller {
57 public: 58 public:
58 TestWebApkInstaller(const ShortcutInfo& shortcut_info, 59 TestWebApkInstaller(const ShortcutInfo& shortcut_info,
59 const SkBitmap& shortcut_icon) 60 const SkBitmap& shortcut_icon)
60 : WebApkInstaller(shortcut_info, shortcut_icon) {} 61 : WebApkInstaller(shortcut_info, shortcut_icon) {}
61 62
62 bool StartInstallingDownloadedWebApk( 63 bool StartInstallingDownloadedWebApk(
63 JNIEnv* env, 64 JNIEnv* env,
64 const base::android::ScopedJavaLocalRef<jstring>& file_path, 65 const base::android::ScopedJavaLocalRef<jstring>& file_path,
65 const base::android::ScopedJavaLocalRef<jstring>& package_name) override { 66 const base::android::ScopedJavaLocalRef<jstring>& package_name) override {
66 PostTaskToRunSuccessCallback(); 67 PostTaskToRunSuccessCallback();
67 return true; 68 return true;
68 } 69 }
69 70
70 bool StartUpdateUsingDownloadedWebApk( 71 bool StartUpdateUsingDownloadedWebApk(
71 JNIEnv* env, 72 JNIEnv* env,
72 const base::android::ScopedJavaLocalRef<jstring>& file_path) override { 73 const base::android::ScopedJavaLocalRef<jstring>& file_path) override {
73 return true; 74 return true;
74 } 75 }
75 76
77 bool HasGooglePlayWebApkInstallDelegate() override {
78 return false;
79 }
80
76 void PostTaskToRunSuccessCallback() { 81 void PostTaskToRunSuccessCallback() {
77 base::ThreadTaskRunnerHandle::Get()->PostTask( 82 base::ThreadTaskRunnerHandle::Get()->PostTask(
78 FROM_HERE, 83 FROM_HERE,
79 base::Bind(&TestWebApkInstaller::OnSuccess, base::Unretained(this))); 84 base::Bind(&TestWebApkInstaller::OnSuccess, base::Unretained(this)));
80 } 85 }
81 86
82 private: 87 private:
83 DISALLOW_COPY_AND_ASSIGN(TestWebApkInstaller); 88 DISALLOW_COPY_AND_ASSIGN(TestWebApkInstaller);
84 }; 89 };
85 90
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 std::unique_ptr<WebApkInstallerRunner> runner = CreateWebApkInstallerRunner(); 328 std::unique_ptr<WebApkInstallerRunner> runner = CreateWebApkInstallerRunner();
324 runner->RunInstallWebApk(); 329 runner->RunInstallWebApk();
325 EXPECT_FALSE(runner->success()); 330 EXPECT_FALSE(runner->success());
326 } 331 }
327 332
328 // Test update succeeding. 333 // Test update succeeding.
329 TEST_F(WebApkInstallerTest, UpdateSuccess) { 334 TEST_F(WebApkInstallerTest, UpdateSuccess) {
330 std::unique_ptr<WebApkInstallerRunner> runner = CreateWebApkInstallerRunner(); 335 std::unique_ptr<WebApkInstallerRunner> runner = CreateWebApkInstallerRunner();
331 runner->RunUpdateWebApk(); 336 runner->RunUpdateWebApk();
332 EXPECT_TRUE(runner->success()); 337 EXPECT_TRUE(runner->success());
333 } 338 }
pkotwicz 2016/12/02 22:27:04 Can you add a test testing the Google Play install
Xi Han 2016/12/05 17:27:54 Done.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698