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

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

Issue 2259553002: Make AppBannerInfoBar install WebAPK. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add a TODO. 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 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 class TestWebApkInstaller : public WebApkInstaller { 59 class TestWebApkInstaller : public WebApkInstaller {
60 public: 60 public:
61 TestWebApkInstaller(const ShortcutInfo& shortcut_info, 61 TestWebApkInstaller(const ShortcutInfo& shortcut_info,
62 const SkBitmap& shortcut_icon) 62 const SkBitmap& shortcut_icon)
63 : WebApkInstaller(shortcut_info, shortcut_icon) {} 63 : WebApkInstaller(shortcut_info, shortcut_icon) {}
64 64
65 bool StartInstallingDownloadedWebApk( 65 bool StartInstallingDownloadedWebApk(
66 JNIEnv* env, 66 JNIEnv* env,
67 const base::android::ScopedJavaLocalRef<jstring>& file_path, 67 const base::android::ScopedJavaLocalRef<jstring>& file_path,
68 const base::android::ScopedJavaLocalRef<jstring>& package_name) override { 68 const base::android::ScopedJavaLocalRef<jstring>& package_name) override {
69 OnSuccess();
gone 2016/08/29 17:24:09 This isn't exactly like the code flow it's testing
Xi Han 2016/08/29 17:55:46 Done.
69 return true; 70 return true;
70 } 71 }
71 72
72 bool StartUpdateUsingDownloadedWebApk( 73 bool StartUpdateUsingDownloadedWebApk(
73 JNIEnv* env, 74 JNIEnv* env,
74 const base::android::ScopedJavaLocalRef<jstring>& file_path, 75 const base::android::ScopedJavaLocalRef<jstring>& file_path,
75 const base::android::ScopedJavaLocalRef<jstring>& package_name) override { 76 const base::android::ScopedJavaLocalRef<jstring>& package_name) override {
77 OnSuccess();
76 return true; 78 return true;
77 } 79 }
78 80
79 private: 81 private:
80 DISALLOW_COPY_AND_ASSIGN(TestWebApkInstaller); 82 DISALLOW_COPY_AND_ASSIGN(TestWebApkInstaller);
81 }; 83 };
82 84
83 // Runs the WebApkInstaller installation process/update and blocks till done. 85 // Runs the WebApkInstaller installation process/update and blocks till done.
84 class WebApkInstallerRunner { 86 class WebApkInstallerRunner {
85 public: 87 public:
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 129
128 void Run() { 130 void Run() {
129 base::RunLoop run_loop; 131 base::RunLoop run_loop;
130 on_completed_callback_ = run_loop.QuitClosure(); 132 on_completed_callback_ = run_loop.QuitClosure();
131 run_loop.Run(); 133 run_loop.Run();
132 } 134 }
133 135
134 bool success() { return success_; } 136 bool success() { return success_; }
135 137
136 private: 138 private:
137 void OnCompleted(bool success) { 139 void OnCompleted(bool success, const std::string& webapk_package) {
138 success_ = success; 140 success_ = success;
139 on_completed_callback_.Run(); 141 on_completed_callback_.Run();
140 } 142 }
141 143
142 scoped_refptr<net::TestURLRequestContextGetter> 144 scoped_refptr<net::TestURLRequestContextGetter>
143 url_request_context_getter_; 145 url_request_context_getter_;
144 146
145 // The Web Manifest's icon URL. 147 // The Web Manifest's icon URL.
146 const GURL icon_url_; 148 const GURL icon_url_;
147 149
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 runner->RunInstallWebApk(); 335 runner->RunInstallWebApk();
334 EXPECT_FALSE(runner->success()); 336 EXPECT_FALSE(runner->success());
335 } 337 }
336 338
337 // Test update succeeding. 339 // Test update succeeding.
338 TEST_F(WebApkInstallerTest, UpdateSuccess) { 340 TEST_F(WebApkInstallerTest, UpdateSuccess) {
339 std::unique_ptr<WebApkInstallerRunner> runner = CreateWebApkInstallerRunner(); 341 std::unique_ptr<WebApkInstallerRunner> runner = CreateWebApkInstallerRunner();
340 runner->RunUpdateWebApk(); 342 runner->RunUpdateWebApk();
341 EXPECT_TRUE(runner->success()); 343 EXPECT_TRUE(runner->success());
342 } 344 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698