Chromium Code Reviews| 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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::OnCompleted, |
| 98 base::Unretained(this))); | 98 base::Unretained(this))); |
| 99 Run(); | 99 Run(); |
| 100 } | 100 } |
| 101 | 101 |
| 102 void RunUpdateWebApk() { | 102 void RunUpdateWebApk() { |
| 103 const int webapk_version = 1; | 103 const int kWebApkVersion = 1; |
| 104 const std::string kIconMurmur2Hash = "0"; | |
|
pkotwicz
2016/08/26 21:24:37
Nit: Order |kIconMurmur2Hash| before |kWebApkVersi
Xi Han
2016/08/29 15:33:22
Done.
| |
| 104 | 105 |
| 105 WebApkInstaller* installer = CreateWebApkInstaller(); | 106 WebApkInstaller* installer = CreateWebApkInstaller(); |
| 106 | 107 |
| 107 installer->UpdateAsyncWithURLRequestContextGetter( | 108 installer->UpdateAsyncWithURLRequestContextGetter( |
| 108 url_request_context_getter_.get(), | 109 url_request_context_getter_.get(), |
| 109 base::Bind(&WebApkInstallerRunner::OnCompleted, base::Unretained(this)), | 110 base::Bind(&WebApkInstallerRunner::OnCompleted, base::Unretained(this)), |
| 111 kIconMurmur2Hash, | |
| 110 kDownloadedWebApkPackageName, | 112 kDownloadedWebApkPackageName, |
| 111 webapk_version); | 113 kWebApkVersion); |
| 112 | 114 |
| 113 Run(); | 115 Run(); |
| 114 } | 116 } |
| 115 | 117 |
| 116 WebApkInstaller* CreateWebApkInstaller() { | 118 WebApkInstaller* CreateWebApkInstaller() { |
| 117 ShortcutInfo info(GURL::EmptyGURL()); | 119 ShortcutInfo info(GURL::EmptyGURL()); |
| 118 info.icon_url = icon_url_; | 120 info.icon_url = icon_url_; |
| 119 | 121 |
| 120 // WebApkInstaller owns itself. | 122 // WebApkInstaller owns itself. |
| 121 WebApkInstaller* installer = new TestWebApkInstaller(info, SkBitmap()); | 123 WebApkInstaller* installer = new TestWebApkInstaller(info, SkBitmap()); |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 331 runner->RunInstallWebApk(); | 333 runner->RunInstallWebApk(); |
| 332 EXPECT_FALSE(runner->success()); | 334 EXPECT_FALSE(runner->success()); |
| 333 } | 335 } |
| 334 | 336 |
| 335 // Test update succeeding. | 337 // Test update succeeding. |
| 336 TEST_F(WebApkInstallerTest, UpdateSuccess) { | 338 TEST_F(WebApkInstallerTest, UpdateSuccess) { |
| 337 std::unique_ptr<WebApkInstallerRunner> runner = CreateWebApkInstallerRunner(); | 339 std::unique_ptr<WebApkInstallerRunner> runner = CreateWebApkInstallerRunner(); |
| 338 runner->RunUpdateWebApk(); | 340 runner->RunUpdateWebApk(); |
| 339 EXPECT_TRUE(runner->success()); | 341 EXPECT_TRUE(runner->success()); |
| 340 } | 342 } |
| OLD | NEW |