Chromium Code Reviews| Index: chrome/browser/extensions/api/sync_file_system/sync_file_system_apitest.cc |
| diff --git a/chrome/browser/extensions/api/sync_file_system/sync_file_system_apitest.cc b/chrome/browser/extensions/api/sync_file_system/sync_file_system_apitest.cc |
| index ef04e015ba74d4318e4a28ed5e36910cb7c1429d..eb57cd520965a5b5af0e9041a90e0d2b40c82f35 100644 |
| --- a/chrome/browser/extensions/api/sync_file_system/sync_file_system_apitest.cc |
| +++ b/chrome/browser/extensions/api/sync_file_system/sync_file_system_apitest.cc |
| @@ -13,6 +13,7 @@ |
| #include "chrome/common/chrome_version_info.h" |
| #include "chrome/common/extensions/features/feature.h" |
| #include "testing/gtest/include/gtest/gtest.h" |
| +#include "webkit/fileapi/file_system_url.h" |
| #include "webkit/fileapi/syncable/sync_status_code.h" |
| #include "webkit/quota/quota_manager.h" |
| @@ -66,6 +67,23 @@ ACTION_P(NotifyOkStateAndCallback, mock_remote_service) { |
| FROM_HERE, base::Bind(arg1, fileapi::SYNC_STATUS_OK)); |
| } |
| +ACTION_P2(UpdateRemoteChangeQueue, origin, mock_remote_service) { |
| + *origin = arg0; |
| + mock_remote_service->NotifyRemoteChangeQueueUpdated(1); |
| +} |
| + |
| +ACTION_P2(ProcessRemoteChangeAndCallBack, origin, mock_remote_service) { |
|
kinuko
2013/01/08 12:59:18
Since this action doesn't actually process remote
calvinlo
2013/01/09 04:54:32
Done.
|
| + fileapi::FileSystemURL mock_url(*origin, |
| + fileapi::kFileSystemTypeTest, |
| + FilePath(FILE_PATH_LITERAL("foo"))); |
|
kinuko
2013/01/08 12:59:18
nit: indent
calvinlo
2013/01/09 04:54:32
Done.
|
| + mock_remote_service->NotifyRemoteChangeQueueUpdated(0); |
| + base::MessageLoopProxy::current()->PostTask( |
| + FROM_HERE, base::Bind(arg1, |
| + fileapi::SYNC_STATUS_OK, |
| + mock_url, |
| + fileapi::SYNC_OPERATION_ADDED)); |
| +} |
| + |
| } // namespace |
| // TODO(calvinlo): Add Chrome OS support for syncable file system |
| @@ -82,9 +100,20 @@ IN_PROC_BROWSER_TEST_F(SyncFileSystemApiTest, GetUsageAndQuota) { |
| << message_; |
| } |
| +IN_PROC_BROWSER_TEST_F(SyncFileSystemApiTest, OnFileSynced) { |
| + // Mock a pending remote change to be synced. |
| + GURL origin; |
| + EXPECT_CALL(*mock_remote_service(), RegisterOriginForTrackingChanges(_, _)) |
| + .WillOnce(UpdateRemoteChangeQueue(&origin, mock_remote_service())); |
| + EXPECT_CALL(*mock_remote_service(), ProcessRemoteChange(_, _)) |
| + .WillOnce(ProcessRemoteChangeAndCallBack(&origin, |
| + mock_remote_service())); |
| + ASSERT_TRUE(RunPlatformAppTest("sync_file_system/on_file_synced")) |
| + << message_; |
| +} |
| + |
| IN_PROC_BROWSER_TEST_F(SyncFileSystemApiTest, OnSyncStateChanged) { |
| - EXPECT_CALL(*mock_remote_service(), |
| - RegisterOriginForTrackingChanges(_, _)) |
| + EXPECT_CALL(*mock_remote_service(), RegisterOriginForTrackingChanges(_, _)) |
| .WillOnce(NotifyOkStateAndCallback(mock_remote_service())); |
| ASSERT_TRUE(RunPlatformAppTest("sync_file_system/on_sync_state_changed")) |
| << message_; |