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

Unified Diff: content/browser/service_worker/service_worker_storage_unittest.cc

Issue 657023012: Fix ServiceWorkerResourceStorageDiskTest.CleanupOnRestart flakiness on Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/service_worker/service_worker_storage_unittest.cc
diff --git a/content/browser/service_worker/service_worker_storage_unittest.cc b/content/browser/service_worker/service_worker_storage_unittest.cc
index c6687a6f4f1b0e78d3a97d9f1ccc008bb015da35..57305d9812ae0293feaa5d2af06dcdfa52c79eff 100644
--- a/content/browser/service_worker/service_worker_storage_unittest.cc
+++ b/content/browser/service_worker/service_worker_storage_unittest.cc
@@ -79,10 +79,6 @@ ServiceWorkerStorage::GetAllRegistrationInfosCallback MakeGetAllCallback(
return base::Bind(&GetAllCallback, was_called, all);
}
-void OnIOComplete(int* rv_out, int rv) {
- *rv_out = rv;
-}
-
void OnCompareComplete(
ServiceWorkerStatusCode* status_out, bool* are_equal_out,
ServiceWorkerStatusCode status, bool are_equal) {
@@ -104,16 +100,18 @@ void WriteResponse(
info->headers = new net::HttpResponseHeaders(headers);
scoped_refptr<HttpResponseInfoIOBuffer> info_buffer =
new HttpResponseInfoIOBuffer(info.release());
-
- int rv = -1234;
- writer->WriteInfo(info_buffer.get(), base::Bind(&OnIOComplete, &rv));
- base::RunLoop().RunUntilIdle();
- EXPECT_LT(0, rv);
-
- rv = -1234;
- writer->WriteData(body, length, base::Bind(&OnIOComplete, &rv));
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(length, rv);
+ {
+ TestCompletionCallback cb;
+ writer->WriteInfo(info_buffer.get(), cb.callback());
+ int rv = cb.WaitForResult();
+ EXPECT_LT(0, rv);
+ }
+ {
+ TestCompletionCallback cb;
+ writer->WriteData(body, length, cb.callback());
+ int rv = cb.WaitForResult();
+ EXPECT_EQ(length, rv);
+ }
}
void WriteStringResponse(
@@ -750,13 +748,7 @@ TEST_F(ServiceWorkerResourceStorageTest, DeleteRegistration_ActiveVersion) {
EXPECT_FALSE(VerifyBasicResponse(storage(), resource_id2_, false));
}
-// Android has flaky IO error: http://crbug.com/387045
-#if defined(OS_ANDROID)
-#define MAYBE_CleanupOnRestart DISABLED_CleanupOnRestart
-#else
-#define MAYBE_CleanupOnRestart CleanupOnRestart
-#endif
-TEST_F(ServiceWorkerResourceStorageDiskTest, MAYBE_CleanupOnRestart) {
+TEST_F(ServiceWorkerResourceStorageDiskTest, CleanupOnRestart) {
// Promote the worker to active and add a controllee.
registration_->SetActiveVersion(registration_->waiting_version());
registration_->SetWaitingVersion(NULL);
@@ -834,6 +826,11 @@ TEST_F(ServiceWorkerResourceStorageDiskTest, MAYBE_CleanupOnRestart) {
ASSERT_EQ(1u, verify_ids.size());
EXPECT_EQ(kNewResourceId, *verify_ids.begin());
+ // Purging resources needs interactions with SimpleCache's worker thread,
+ // so single RunUntilIdle() call may not be sufficient.
+ while (storage()->is_purge_pending_)
+ base::RunLoop().RunUntilIdle();
+
verify_ids.clear();
EXPECT_EQ(ServiceWorkerDatabase::STATUS_OK,
storage()->database_->GetPurgeableResourceIds(&verify_ids));
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698