Commit 50b4aab5 authored by tzik@chromium.org's avatar tzik@chromium.org

Sync FileSystem: Add default mock expectation for MockDriveService::GetChangeList

BUG=173339

Review URL: https://codereview.chromium.org/14322009

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@194570 0039d316-1c4b-4281-b951-d872f2087c98
parent b5a8b7c8
......@@ -25,6 +25,8 @@ namespace google_apis {
MockDriveService::MockDriveService() {
ON_CALL(*this, GetProgressStatusList())
.WillByDefault(Return(OperationProgressStatusList()));
ON_CALL(*this, GetChangeList(_, _))
.WillByDefault(Invoke(this, &MockDriveService::GetChangeListStub));
ON_CALL(*this, GetAccountMetadata(_))
.WillByDefault(Invoke(this, &MockDriveService::GetAccountMetadataStub));
ON_CALL(*this, DeleteResource(_, _, _))
......@@ -53,6 +55,16 @@ MockDriveService::MockDriveService() {
MockDriveService::~MockDriveService() {}
void MockDriveService::GetChangeListStub(
int64 start_changestamp,
const GetResourceListCallback& callback) {
scoped_ptr<ResourceList> resource_list(new ResourceList());
base::MessageLoopProxy::current()->PostTask(
FROM_HERE,
base::Bind(callback, HTTP_SUCCESS,
base::Passed(&resource_list)));
}
void MockDriveService::GetAccountMetadataStub(
const GetAccountMetadataCallback& callback) {
scoped_ptr<AccountMetadata> account_metadata =
......
......@@ -143,6 +143,10 @@ class MockDriveService : public DriveServiceInterface {
// Helper stub methods for functions which take callbacks, so that
// the callbacks get called with testable results.
// Will call |callback| with HTTP_SUCCESS and a empty ResourceList.
void GetChangeListStub(int64 start_changestamp,
const GetResourceListCallback& callback);
// Will call |callback| with HTTP_SUCCESS and a StringValue with the current
// value of |account_metadata_|.
void GetAccountMetadataStub(const GetAccountMetadataCallback& callback);
......
......@@ -41,6 +41,7 @@ using ::testing::AtLeast;
using ::testing::AtMost;
using ::testing::InSequence;
using ::testing::Return;
using ::testing::NiceMock;
using ::testing::Sequence;
using ::testing::StrictMock;
using ::testing::_;
......@@ -204,14 +205,6 @@ ACTION(InvokeDidApplyRemoteChange) {
FROM_HERE, base::Bind(arg3, SYNC_STATUS_OK));
}
ACTION(InvokeGetChangeListWithEmptyChange) {
scoped_ptr<google_apis::ResourceList> resource_list(
new google_apis::ResourceList());
base::MessageLoopProxy::current()->PostTask(
FROM_HERE, base::Bind(arg1, google_apis::HTTP_SUCCESS,
base::Passed(&resource_list)));
}
} // namespace
class MockRemoteServiceObserver : public RemoteFileSyncService::Observer {
......@@ -264,7 +257,7 @@ class DriveFileSyncServiceMockTest : public testing::Test {
ASSERT_TRUE(RegisterSyncableFileSystem(kServiceName));
mock_drive_service_ = new StrictMock<google_apis::MockDriveService>;
mock_drive_service_ = new NiceMock<google_apis::MockDriveService>;
EXPECT_CALL(*mock_drive_service(), Initialize(profile_.get()));
EXPECT_CALL(*mock_drive_service(), AddObserver(_));
......@@ -437,7 +430,7 @@ class DriveFileSyncServiceMockTest : public testing::Test {
return sync_service_->metadata_store_.get();
}
StrictMock<google_apis::MockDriveService>* mock_drive_service() {
NiceMock<google_apis::MockDriveService>* mock_drive_service() {
return mock_drive_service_;
}
......@@ -634,13 +627,6 @@ class DriveFileSyncServiceMockTest : public testing::Test {
.RetiresOnSaturation();
}
void SetUpDriveServiceExpectCallsForEmptyRemoteChange() {
EXPECT_CALL(*mock_drive_service(),
GetChangeList(_, _))
.WillOnce(InvokeGetChangeListWithEmptyChange())
.RetiresOnSaturation();
}
// End of mock setup helpers -----------------------------------------------
private:
......@@ -657,7 +643,7 @@ class DriveFileSyncServiceMockTest : public testing::Test {
ExtensionService* extension_service_;
// Owned by |sync_client_|.
StrictMock<google_apis::MockDriveService>* mock_drive_service_;
NiceMock<google_apis::MockDriveService>* mock_drive_service_;
StrictMock<MockRemoteServiceObserver> mock_remote_observer_;
StrictMock<MockFileStatusObserver> mock_file_status_observer_;
......@@ -761,8 +747,6 @@ TEST_F(DriveFileSyncServiceMockTest, RegisterNewOrigin) {
"chromeos/sync_file_system/listing_files_in_empty_directory.json",
kDirectoryResourceId);
SetUpDriveServiceExpectCallsForEmptyRemoteChange();
SetUpDriveSyncService(true);
bool done = false;
sync_service()->RegisterOriginForTrackingChanges(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment