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

Unified Diff: chrome/browser/android/webapk/webapk_icon_hasher_unittest.cc

Issue 2771793003: Move timeout timer into WebApkIconHasher (Closed)
Patch Set: Remove weakptr and use unretained Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/android/webapk/webapk_icon_hasher_unittest.cc
diff --git a/chrome/browser/android/webapk/webapk_icon_hasher_unittest.cc b/chrome/browser/android/webapk/webapk_icon_hasher_unittest.cc
index ba4cc6dda7cc6ece4ce039a056a312ef1d59448f..b01c2d94d003b2ce3f825d1832e81d8c17d89b75 100644
--- a/chrome/browser/android/webapk/webapk_icon_hasher_unittest.cc
+++ b/chrome/browser/android/webapk/webapk_icon_hasher_unittest.cc
@@ -37,11 +37,10 @@ class WebApkIconHasherRunner {
~WebApkIconHasherRunner() {}
void Run(const GURL& icon_url) {
- WebApkIconHasher hasher;
- hasher.DownloadAndComputeMurmur2Hash(
- url_request_context_getter_.get(), icon_url,
+ WebApkIconHasher hasher(url_request_context_getter_.get(), icon_url,
base::Bind(&WebApkIconHasherRunner::OnCompleted,
base::Unretained(this)));
+ hasher.DownloadAndComputeMurmur2Hash();
base::RunLoop run_loop;
on_completed_callback_ = run_loop.QuitClosure();
@@ -113,6 +112,20 @@ TEST_F(WebApkIconHasherTest, DataUriInvalid) {
EXPECT_EQ("", runner.murmur2_hash());
}
+TEST_F(WebApkIconHasherTest, InvalidUrl) {
+ GURL icon_url("http::google.com");
+ WebApkIconHasherRunner runner;
+ runner.Run(icon_url);
+ EXPECT_EQ("", runner.murmur2_hash());
+}
+
+TEST_F(WebApkIconHasherTest, DownloadTimedOut) {
+ GURL icon_url = test_server()->GetURL("/slow?100");
+ WebApkIconHasherRunner runner;
+ runner.Run(icon_url);
+ EXPECT_EQ("", runner.murmur2_hash());
+}
+
// Test that the hash callback is called with an empty string if an HTTP error
// prevents the icon URL from being fetched.
TEST_F(WebApkIconHasherTest, HTTPError) {
« no previous file with comments | « chrome/browser/android/webapk/webapk_icon_hasher.cc ('k') | chrome/browser/android/webapk/webapk_installer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698