| OLD | NEW |
| 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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 : url_request_context_getter_(new net::TestURLRequestContextGetter( | 87 : url_request_context_getter_(new net::TestURLRequestContextGetter( |
| 88 base::ThreadTaskRunnerHandle::Get())), | 88 base::ThreadTaskRunnerHandle::Get())), |
| 89 icon_url_(icon_url) {} | 89 icon_url_(icon_url) {} |
| 90 ~WebApkInstallerRunner() {} | 90 ~WebApkInstallerRunner() {} |
| 91 | 91 |
| 92 void RunInstallWebApk() { | 92 void RunInstallWebApk() { |
| 93 WebApkInstaller* installer = CreateWebApkInstaller(); | 93 WebApkInstaller* installer = CreateWebApkInstaller(); |
| 94 | 94 |
| 95 installer->InstallAsyncWithURLRequestContextGetter( | 95 installer->InstallAsyncWithURLRequestContextGetter( |
| 96 url_request_context_getter_.get(), | 96 url_request_context_getter_.get(), |
| 97 base::Bind(&WebApkInstallerRunner::OnCompleted, | 97 base::Bind(&WebApkInstallerRunner::OnWebApkPackageNameAvailable, |
| 98 base::Unretained(this), |
| 99 &WebApkInstallerRunner::OnCompleted, |
| 98 base::Unretained(this))); | 100 base::Unretained(this))); |
| 99 Run(); | 101 Run(); |
| 100 } | 102 } |
| 101 | 103 |
| 102 void RunUpdateWebApk() { | 104 void RunUpdateWebApk() { |
| 103 const int webapk_version = 1; | 105 const int webapk_version = 1; |
| 104 | 106 |
| 105 WebApkInstaller* installer = CreateWebApkInstaller(); | 107 WebApkInstaller* installer = CreateWebApkInstaller(); |
| 106 | 108 |
| 107 installer->UpdateAsyncWithURLRequestContextGetter( | 109 installer->UpdateAsyncWithURLRequestContextGetter( |
| (...skipping 17 matching lines...) Expand all Loading... |
| 125 | 127 |
| 126 void Run() { | 128 void Run() { |
| 127 base::RunLoop run_loop; | 129 base::RunLoop run_loop; |
| 128 on_completed_callback_ = run_loop.QuitClosure(); | 130 on_completed_callback_ = run_loop.QuitClosure(); |
| 129 run_loop.Run(); | 131 run_loop.Run(); |
| 130 } | 132 } |
| 131 | 133 |
| 132 bool success() { return success_; } | 134 bool success() { return success_; } |
| 133 | 135 |
| 134 private: | 136 private: |
| 137 void OnWebApkPackageNameAvailable(const std::string& webapk_package) {} |
| 138 |
| 135 void OnCompleted(bool success) { | 139 void OnCompleted(bool success) { |
| 136 success_ = success; | 140 success_ = success; |
| 137 on_completed_callback_.Run(); | 141 on_completed_callback_.Run(); |
| 138 } | 142 } |
| 139 | 143 |
| 140 scoped_refptr<net::TestURLRequestContextGetter> | 144 scoped_refptr<net::TestURLRequestContextGetter> |
| 141 url_request_context_getter_; | 145 url_request_context_getter_; |
| 142 | 146 |
| 143 // The Web Manifest's icon URL. | 147 // The Web Manifest's icon URL. |
| 144 const GURL icon_url_; | 148 const GURL icon_url_; |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 runner->RunInstallWebApk(); | 335 runner->RunInstallWebApk(); |
| 332 EXPECT_FALSE(runner->success()); | 336 EXPECT_FALSE(runner->success()); |
| 333 } | 337 } |
| 334 | 338 |
| 335 // Test update succeeding. | 339 // Test update succeeding. |
| 336 TEST_F(WebApkInstallerTest, UpdateSuccess) { | 340 TEST_F(WebApkInstallerTest, UpdateSuccess) { |
| 337 std::unique_ptr<WebApkInstallerRunner> runner = CreateWebApkInstallerRunner(); | 341 std::unique_ptr<WebApkInstallerRunner> runner = CreateWebApkInstallerRunner(); |
| 338 runner->RunUpdateWebApk(); | 342 runner->RunUpdateWebApk(); |
| 339 EXPECT_TRUE(runner->success()); | 343 EXPECT_TRUE(runner->success()); |
| 340 } | 344 } |
| OLD | NEW |