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

Side by Side Diff: chrome/browser/google_apis/mock_drive_service.cc

Issue 14322009: Sync FileSystem: Add default mock expectation for MockDriveService::GetChangeList (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: s/StrictMock/NiceMock/ Created 7 years, 8 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/google_apis/mock_drive_service.h" 5 #include "chrome/browser/google_apis/mock_drive_service.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/json/json_file_value_serializer.h" 10 #include "base/json/json_file_value_serializer.h"
11 #include "base/location.h" 11 #include "base/location.h"
12 #include "base/message_loop_proxy.h" 12 #include "base/message_loop_proxy.h"
13 #include "base/path_service.h" 13 #include "base/path_service.h"
14 #include "base/platform_file.h" 14 #include "base/platform_file.h"
15 #include "chrome/browser/google_apis/gdata_wapi_parser.h" 15 #include "chrome/browser/google_apis/gdata_wapi_parser.h"
16 #include "chrome/browser/google_apis/test_util.h" 16 #include "chrome/browser/google_apis/test_util.h"
17 #include "testing/gmock/include/gmock/gmock.h" 17 #include "testing/gmock/include/gmock/gmock.h"
18 18
19 using ::testing::_; 19 using ::testing::_;
20 using ::testing::Invoke; 20 using ::testing::Invoke;
21 using ::testing::Return; 21 using ::testing::Return;
22 22
23 namespace google_apis { 23 namespace google_apis {
24 24
25 MockDriveService::MockDriveService() { 25 MockDriveService::MockDriveService() {
26 ON_CALL(*this, GetProgressStatusList()) 26 ON_CALL(*this, GetProgressStatusList())
27 .WillByDefault(Return(OperationProgressStatusList())); 27 .WillByDefault(Return(OperationProgressStatusList()));
28 ON_CALL(*this, GetChangeList(_, _))
29 .WillByDefault(Invoke(this, &MockDriveService::GetChangeListStub));
28 ON_CALL(*this, GetAccountMetadata(_)) 30 ON_CALL(*this, GetAccountMetadata(_))
29 .WillByDefault(Invoke(this, &MockDriveService::GetAccountMetadataStub)); 31 .WillByDefault(Invoke(this, &MockDriveService::GetAccountMetadataStub));
30 ON_CALL(*this, DeleteResource(_, _, _)) 32 ON_CALL(*this, DeleteResource(_, _, _))
31 .WillByDefault(Invoke(this, &MockDriveService::DeleteResourceStub)); 33 .WillByDefault(Invoke(this, &MockDriveService::DeleteResourceStub));
32 ON_CALL(*this, CopyHostedDocument(_, _, _)) 34 ON_CALL(*this, CopyHostedDocument(_, _, _))
33 .WillByDefault(Invoke(this, &MockDriveService::CopyHostedDocumentStub)); 35 .WillByDefault(Invoke(this, &MockDriveService::CopyHostedDocumentStub));
34 ON_CALL(*this, RenameResource(_, _, _)) 36 ON_CALL(*this, RenameResource(_, _, _))
35 .WillByDefault(Invoke(this, &MockDriveService::RenameResourceStub)); 37 .WillByDefault(Invoke(this, &MockDriveService::RenameResourceStub));
36 ON_CALL(*this, AddResourceToDirectory(_, _, _)) 38 ON_CALL(*this, AddResourceToDirectory(_, _, _))
37 .WillByDefault( 39 .WillByDefault(
38 Invoke(this, &MockDriveService::AddResourceToDirectoryStub)); 40 Invoke(this, &MockDriveService::AddResourceToDirectoryStub));
39 ON_CALL(*this, RemoveResourceFromDirectory(_, _, _)) 41 ON_CALL(*this, RemoveResourceFromDirectory(_, _, _))
40 .WillByDefault( 42 .WillByDefault(
41 Invoke(this, &MockDriveService::RemoveResourceFromDirectoryStub)); 43 Invoke(this, &MockDriveService::RemoveResourceFromDirectoryStub));
42 ON_CALL(*this, AddNewDirectory(_, _, _)) 44 ON_CALL(*this, AddNewDirectory(_, _, _))
43 .WillByDefault(Invoke(this, &MockDriveService::CreateDirectoryStub)); 45 .WillByDefault(Invoke(this, &MockDriveService::CreateDirectoryStub));
44 ON_CALL(*this, DownloadFile(_, _, _, _, _, _)) 46 ON_CALL(*this, DownloadFile(_, _, _, _, _, _))
45 .WillByDefault(Invoke(this, &MockDriveService::DownloadFileStub)); 47 .WillByDefault(Invoke(this, &MockDriveService::DownloadFileStub));
46 48
47 // Fill in the default values for mock data. 49 // Fill in the default values for mock data.
48 account_metadata_data_ = 50 account_metadata_data_ =
49 test_util::LoadJSONFile("chromeos/gdata/account_metadata.json"); 51 test_util::LoadJSONFile("chromeos/gdata/account_metadata.json");
50 directory_data_ = 52 directory_data_ =
51 test_util::LoadJSONFile("chromeos/gdata/new_folder_entry.json"); 53 test_util::LoadJSONFile("chromeos/gdata/new_folder_entry.json");
52 } 54 }
53 55
54 MockDriveService::~MockDriveService() {} 56 MockDriveService::~MockDriveService() {}
55 57
58 void MockDriveService::GetChangeListStub(
59 int64 start_changestamp,
60 const GetResourceListCallback& callback) {
61 scoped_ptr<ResourceList> resource_list(new ResourceList());
62 base::MessageLoopProxy::current()->PostTask(
63 FROM_HERE,
64 base::Bind(callback, HTTP_SUCCESS,
65 base::Passed(&resource_list)));
66 }
67
56 void MockDriveService::GetAccountMetadataStub( 68 void MockDriveService::GetAccountMetadataStub(
57 const GetAccountMetadataCallback& callback) { 69 const GetAccountMetadataCallback& callback) {
58 scoped_ptr<AccountMetadata> account_metadata = 70 scoped_ptr<AccountMetadata> account_metadata =
59 AccountMetadata::CreateFrom(*account_metadata_data_); 71 AccountMetadata::CreateFrom(*account_metadata_data_);
60 base::MessageLoopProxy::current()->PostTask( 72 base::MessageLoopProxy::current()->PostTask(
61 FROM_HERE, 73 FROM_HERE,
62 base::Bind(callback, HTTP_SUCCESS, 74 base::Bind(callback, HTTP_SUCCESS,
63 base::Passed(&account_metadata))); 75 base::Passed(&account_metadata)));
64 } 76 }
65 77
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 ASSERT_EQ(file_data_size, 148 ASSERT_EQ(file_data_size,
137 file_util::WriteFile(local_tmp_path, file_data_->data(), 149 file_util::WriteFile(local_tmp_path, file_data_->data(),
138 file_data_size)); 150 file_data_size));
139 } 151 }
140 base::MessageLoopProxy::current()->PostTask( 152 base::MessageLoopProxy::current()->PostTask(
141 FROM_HERE, 153 FROM_HERE,
142 base::Bind(download_action_callback, error, local_tmp_path)); 154 base::Bind(download_action_callback, error, local_tmp_path));
143 } 155 }
144 156
145 } // namespace google_apis 157 } // namespace google_apis
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698