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

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

Issue 2632243004: Don't download identical APKs on update. (Closed)
Patch Set: Nits. Created 3 years, 10 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
« no previous file with comments | « chrome/browser/android/webapk/webapk_installer.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 EXPECT_FALSE(runner->success()); 414 EXPECT_FALSE(runner->success());
415 } 415 }
416 416
417 // Test update succeeding. 417 // Test update succeeding.
418 TEST_F(WebApkInstallerTest, UpdateSuccess) { 418 TEST_F(WebApkInstallerTest, UpdateSuccess) {
419 std::unique_ptr<WebApkInstallerRunner> runner = CreateWebApkInstallerRunner(); 419 std::unique_ptr<WebApkInstallerRunner> runner = CreateWebApkInstallerRunner();
420 runner->RunUpdateWebApk(); 420 runner->RunUpdateWebApk();
421 EXPECT_TRUE(runner->success()); 421 EXPECT_TRUE(runner->success());
422 } 422 }
423 423
424 // Test that an update suceeds if the WebAPK server returns a HTTP response with
425 // an empty download URL. The WebAPK server sends an empty download URL when:
426 // - The server is unable to update the WebAPK in the way that the client
427 // requested.
428 // AND
429 // - The most up to date version of the WebAPK on the server is identical to the
430 // one installed on the client.
431 TEST_F(WebApkInstallerTest, UpdateSuccessWithEmptyDownloadUrlInResponse) {
432 SetWebApkResponseBuilder(base::Bind(&BuildValidWebApkResponse, GURL()));
433
434 std::unique_ptr<WebApkInstallerRunner> runner = CreateWebApkInstallerRunner();
435 runner->RunUpdateWebApk();
436 EXPECT_TRUE(runner->success());
437 }
438
424 // Test installation succeeds using Google Play. 439 // Test installation succeeds using Google Play.
425 TEST_F(WebApkInstallerTest, InstallFromGooglePlaySuccess) { 440 TEST_F(WebApkInstallerTest, InstallFromGooglePlaySuccess) {
426 std::unique_ptr<WebApkInstallerRunner> runner = CreateWebApkInstallerRunner(); 441 std::unique_ptr<WebApkInstallerRunner> runner = CreateWebApkInstallerRunner();
427 runner->SetCanUseGooglePlayInstallService(true); 442 runner->SetCanUseGooglePlayInstallService(true);
428 runner->RunInstallWebApk(); 443 runner->RunInstallWebApk();
429 EXPECT_TRUE(runner->success()); 444 EXPECT_TRUE(runner->success());
430 } 445 }
431 446
432 // When there is no Web Manifest available for a site, an empty 447 // When there is no Web Manifest available for a site, an empty
433 // |best_primary_icon_url| is used to build a WebApk update request. Tests the 448 // |best_primary_icon_url| is used to build a WebApk update request. Tests the
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 icons[i] = manifest.icons(i); 508 icons[i] = manifest.icons(i);
494 509
495 EXPECT_EQ(best_primary_icon_url.spec(), icons[0].src()); 510 EXPECT_EQ(best_primary_icon_url.spec(), icons[0].src());
496 EXPECT_EQ(best_primary_icon_murmur2_hash, icons[0].hash()); 511 EXPECT_EQ(best_primary_icon_murmur2_hash, icons[0].hash());
497 EXPECT_TRUE(icons[0].has_image_data()); 512 EXPECT_TRUE(icons[0].has_image_data());
498 513
499 EXPECT_EQ(icon_url_1.spec(), icons[1].src()); 514 EXPECT_EQ(icon_url_1.spec(), icons[1].src());
500 EXPECT_EQ(icon_murmur2_hash_1, icons[1].hash()); 515 EXPECT_EQ(icon_murmur2_hash_1, icons[1].hash());
501 EXPECT_FALSE(icons[1].has_image_data()); 516 EXPECT_FALSE(icons[1].has_image_data());
502 } 517 }
OLDNEW
« 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