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

Unified Diff: chrome/browser/sync_file_system/drive_backend_v1/drive_file_sync_service_fake_unittest.cc

Issue 80973002: SyncFS: Clean up callbacks in v1 tests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years 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 | chrome/browser/sync_file_system/drive_backend_v1/drive_file_sync_service_sync_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sync_file_system/drive_backend_v1/drive_file_sync_service_fake_unittest.cc
diff --git a/chrome/browser/sync_file_system/drive_backend_v1/drive_file_sync_service_fake_unittest.cc b/chrome/browser/sync_file_system/drive_backend_v1/drive_file_sync_service_fake_unittest.cc
index ac0703641e04d298f3615b7fe9640b89f2c34983..aa68cfc2fc732e919fe9fcbacae7a06334f448f8 100644
--- a/chrome/browser/sync_file_system/drive_backend_v1/drive_file_sync_service_fake_unittest.cc
+++ b/chrome/browser/sync_file_system/drive_backend_v1/drive_file_sync_service_fake_unittest.cc
@@ -23,6 +23,7 @@
#include "chrome/browser/sync_file_system/sync_direction.h"
#include "chrome/browser/sync_file_system/sync_file_metadata.h"
#include "chrome/browser/sync_file_system/sync_file_system.pb.h"
+#include "chrome/browser/sync_file_system/sync_file_system_test_util.h"
#include "chrome/browser/sync_file_system/syncable_file_system_util.h"
#include "chrome/test/base/testing_profile.h"
#include "content/public/test/test_browser_thread_bundle.h"
@@ -78,44 +79,6 @@ void DidInitialize(bool* done, SyncStatusCode status, bool created) {
EXPECT_TRUE(created);
}
-void DidProcessRemoteChange(SyncStatusCode* status_out,
- fileapi::FileSystemURL* url_out,
- SyncStatusCode status,
- const fileapi::FileSystemURL& url) {
- ASSERT_TRUE(status_out);
- ASSERT_TRUE(url_out);
- *status_out = status;
- *url_out = url;
-}
-
-#if !defined(OS_ANDROID)
-void DidGetRemoteVersions(
- SyncStatusCode* status_out,
- std::vector<RemoteFileSyncService::Version>* versions_out,
- SyncStatusCode status,
- const std::vector<RemoteFileSyncService::Version>& versions) {
- *status_out = status;
- *versions_out = versions;
-}
-
-void DidDownloadRemoteVersion(
- SyncStatusCode* status_out,
- webkit_blob::ScopedFile* downloaded_out,
- SyncStatusCode status,
- webkit_blob::ScopedFile downloaded) {
- *status_out = status;
- *downloaded_out = downloaded.Pass();
-}
-#endif // !defined(OS_ANDROID)
-
-void ExpectEqStatus(bool* done,
- SyncStatusCode expected,
- SyncStatusCode actual) {
- EXPECT_FALSE(*done);
- *done = true;
- EXPECT_EQ(expected, actual);
-}
-
// Mocks adding an installed extension to ExtensionService.
scoped_refptr<const extensions::Extension> AddTestExtension(
ExtensionService* extension_service,
@@ -375,7 +338,7 @@ class DriveFileSyncServiceFakeTest : public testing::Test {
}
sync_service_->ProcessRemoteChange(
- base::Bind(&DidProcessRemoteChange, &actual_status, &actual_url));
+ CreateResultReceiver(&actual_status, &actual_url));
base::RunLoop().RunUntilIdle();
EXPECT_EQ(expected_status, actual_status);
@@ -439,12 +402,12 @@ class DriveFileSyncServiceFakeTest : public testing::Test {
metadata.set_to_be_fetched(false);
metadata.set_type(DriveMetadata::RESOURCE_TYPE_FILE);
- bool done = false;
+ SyncStatusCode status = SYNC_STATUS_UNKNOWN;
metadata_store()->UpdateEntry(
CreateURL(origin, title), metadata,
- base::Bind(&ExpectEqStatus, &done, SYNC_STATUS_OK));
+ CreateResultReceiver(&status));
base::RunLoop().RunUntilIdle();
- ASSERT_TRUE(done);
+ ASSERT_EQ(SYNC_STATUS_OK, status);
}
void TestRegisterNewOrigin();
@@ -494,12 +457,12 @@ class DriveFileSyncServiceFakeTest : public testing::Test {
void DriveFileSyncServiceFakeTest::TestRegisterNewOrigin() {
SetUpDriveSyncService(true);
- bool done = false;
+ SyncStatusCode status = SYNC_STATUS_UNKNOWN;
sync_service()->RegisterOrigin(
ExtensionNameToGURL(kExtensionName1),
- base::Bind(&ExpectEqStatus, &done, SYNC_STATUS_OK));
+ CreateResultReceiver(&status));
base::RunLoop().RunUntilIdle();
- EXPECT_TRUE(done);
+ EXPECT_EQ(SYNC_STATUS_OK, status);
VerifySizeOfRegisteredOrigins(0u, 1u, 0u);
EXPECT_TRUE(!remote_change_handler().HasChanges());
@@ -522,12 +485,12 @@ void DriveFileSyncServiceFakeTest::TestRegisterExistingOrigin() {
SetUpDriveSyncService(true);
- bool done = false;
+ SyncStatusCode status = SYNC_STATUS_UNKNOWN;
sync_service()->RegisterOrigin(
ExtensionNameToGURL(kExtensionName1),
- base::Bind(&ExpectEqStatus, &done, SYNC_STATUS_OK));
+ CreateResultReceiver(&status));
base::RunLoop().RunUntilIdle();
- EXPECT_TRUE(done);
+ EXPECT_EQ(SYNC_STATUS_OK, status);
// The origin should be registered as an incremental sync origin.
VerifySizeOfRegisteredOrigins(0u, 1u, 0u);
@@ -542,12 +505,12 @@ void DriveFileSyncServiceFakeTest::TestRegisterOriginWithSyncDisabled() {
// still return OK).
SetUpDriveSyncService(false);
- bool done = false;
+ SyncStatusCode status = SYNC_STATUS_UNKNOWN;
sync_service()->RegisterOrigin(
ExtensionNameToGURL(kExtensionName1),
- base::Bind(&ExpectEqStatus, &done, SYNC_STATUS_OK));
+ CreateResultReceiver(&status));
base::RunLoop().RunUntilIdle();
- EXPECT_TRUE(done);
+ EXPECT_EQ(SYNC_STATUS_OK, status);
// We must not have started batch sync for the newly registered origin,
// so it should still be in the batch_sync_origins.
@@ -564,13 +527,13 @@ void DriveFileSyncServiceFakeTest::TestUninstallOrigin() {
VerifySizeOfRegisteredOrigins(0u, 2u, 0u);
EXPECT_EQ(0u, remote_change_handler().ChangesSize());
- bool done = false;
+ SyncStatusCode status = SYNC_STATUS_UNKNOWN;
sync_service()->UninstallOrigin(
ExtensionNameToGURL(kExtensionName1),
RemoteFileSyncService::UNINSTALL_AND_PURGE_REMOTE,
- base::Bind(&ExpectEqStatus, &done, SYNC_STATUS_OK));
+ CreateResultReceiver(&status));
base::RunLoop().RunUntilIdle();
- EXPECT_TRUE(done);
+ EXPECT_EQ(SYNC_STATUS_OK, status);
VerifySizeOfRegisteredOrigins(0u, 1u, 0u);
EXPECT_TRUE(!remote_change_handler().HasChanges());
@@ -800,7 +763,7 @@ void DriveFileSyncServiceFakeTest::TestGetRemoteVersions() {
SyncStatusCode status = SYNC_STATUS_FAILED;
std::vector<RemoteFileSyncService::Version> versions;
sync_service_->GetRemoteVersions(
- url, base::Bind(&DidGetRemoteVersions, &status, &versions));
+ url, CreateResultReceiver(&status, &versions));
base::RunLoop().RunUntilIdle();
ASSERT_EQ(SYNC_STATUS_OK, status);
@@ -813,8 +776,7 @@ void DriveFileSyncServiceFakeTest::TestGetRemoteVersions() {
status = SYNC_STATUS_FAILED;
webkit_blob::ScopedFile downloaded;
sync_service_->DownloadRemoteVersion(
- url, versions[0].id,
- base::Bind(&DidDownloadRemoteVersion, &status, &downloaded));
+ url, versions[0].id, CreateResultReceiver(&status, &downloaded));
base::RunLoop().RunUntilIdle();
ASSERT_EQ(SYNC_STATUS_OK, status);
« no previous file with comments | « no previous file | chrome/browser/sync_file_system/drive_backend_v1/drive_file_sync_service_sync_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698