OLD | NEW |
---|---|
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 "base/file_util.h" | 5 #include "base/file_util.h" |
6 #include "base/path_service.h" | 6 #include "base/path_service.h" |
7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
8 #include "chrome/browser/extensions/event_names.h" | 8 #include "chrome/browser/extensions/event_names.h" |
9 #include "chrome/browser/extensions/extension_apitest.h" | 9 #include "chrome/browser/extensions/extension_apitest.h" |
10 #include "chrome/browser/sync_file_system/local_change_processor.h" | 10 #include "chrome/browser/sync_file_system/local_change_processor.h" |
11 #include "chrome/browser/sync_file_system/mock_remote_file_sync_service.h" | 11 #include "chrome/browser/sync_file_system/mock_remote_file_sync_service.h" |
12 #include "chrome/browser/sync_file_system/sync_file_system_service.h" | 12 #include "chrome/browser/sync_file_system/sync_file_system_service.h" |
13 #include "chrome/common/chrome_version_info.h" | 13 #include "chrome/common/chrome_version_info.h" |
14 #include "chrome/common/extensions/features/feature.h" | 14 #include "chrome/common/extensions/features/feature.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
16 #include "webkit/fileapi/file_system_url.h" | |
16 #include "webkit/fileapi/syncable/sync_status_code.h" | 17 #include "webkit/fileapi/syncable/sync_status_code.h" |
17 #include "webkit/quota/quota_manager.h" | 18 #include "webkit/quota/quota_manager.h" |
18 | 19 |
19 using sync_file_system::MockRemoteFileSyncService; | 20 using sync_file_system::MockRemoteFileSyncService; |
20 using sync_file_system::RemoteFileSyncService; | 21 using sync_file_system::RemoteFileSyncService; |
21 using sync_file_system::SyncFileSystemServiceFactory; | 22 using sync_file_system::SyncFileSystemServiceFactory; |
22 using ::testing::_; | 23 using ::testing::_; |
23 | 24 |
24 namespace chrome { | 25 namespace chrome { |
25 | 26 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
59 int64 real_default_quota_; | 60 int64 real_default_quota_; |
60 }; | 61 }; |
61 | 62 |
62 ACTION_P(NotifyOkStateAndCallback, mock_remote_service) { | 63 ACTION_P(NotifyOkStateAndCallback, mock_remote_service) { |
63 mock_remote_service->NotifyRemoteServiceStateUpdated( | 64 mock_remote_service->NotifyRemoteServiceStateUpdated( |
64 sync_file_system::REMOTE_SERVICE_OK, "Test event description."); | 65 sync_file_system::REMOTE_SERVICE_OK, "Test event description."); |
65 base::MessageLoopProxy::current()->PostTask( | 66 base::MessageLoopProxy::current()->PostTask( |
66 FROM_HERE, base::Bind(arg1, fileapi::SYNC_STATUS_OK)); | 67 FROM_HERE, base::Bind(arg1, fileapi::SYNC_STATUS_OK)); |
67 } | 68 } |
68 | 69 |
70 ACTION_P2(UpdateRemoteChangeQueue, origin, mock_remote_service) { | |
71 *origin = arg0; | |
72 mock_remote_service->NotifyRemoteChangeQueueUpdated(1); | |
73 } | |
74 | |
75 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.
| |
76 fileapi::FileSystemURL mock_url(*origin, | |
77 fileapi::kFileSystemTypeTest, | |
78 FilePath(FILE_PATH_LITERAL("foo"))); | |
kinuko
2013/01/08 12:59:18
nit: indent
calvinlo
2013/01/09 04:54:32
Done.
| |
79 mock_remote_service->NotifyRemoteChangeQueueUpdated(0); | |
80 base::MessageLoopProxy::current()->PostTask( | |
81 FROM_HERE, base::Bind(arg1, | |
82 fileapi::SYNC_STATUS_OK, | |
83 mock_url, | |
84 fileapi::SYNC_OPERATION_ADDED)); | |
85 } | |
86 | |
69 } // namespace | 87 } // namespace |
70 | 88 |
71 // TODO(calvinlo): Add Chrome OS support for syncable file system | 89 // TODO(calvinlo): Add Chrome OS support for syncable file system |
72 // (http://crbug.com/160693) | 90 // (http://crbug.com/160693) |
73 #if !defined(OS_CHROMEOS) | 91 #if !defined(OS_CHROMEOS) |
74 | 92 |
75 IN_PROC_BROWSER_TEST_F(SyncFileSystemApiTest, DeleteFileSystem) { | 93 IN_PROC_BROWSER_TEST_F(SyncFileSystemApiTest, DeleteFileSystem) { |
76 ASSERT_TRUE(RunPlatformAppTest("sync_file_system/delete_file_system")) | 94 ASSERT_TRUE(RunPlatformAppTest("sync_file_system/delete_file_system")) |
77 << message_; | 95 << message_; |
78 } | 96 } |
79 | 97 |
80 IN_PROC_BROWSER_TEST_F(SyncFileSystemApiTest, GetUsageAndQuota) { | 98 IN_PROC_BROWSER_TEST_F(SyncFileSystemApiTest, GetUsageAndQuota) { |
81 ASSERT_TRUE(RunExtensionTest("sync_file_system/get_usage_and_quota")) | 99 ASSERT_TRUE(RunExtensionTest("sync_file_system/get_usage_and_quota")) |
82 << message_; | 100 << message_; |
83 } | 101 } |
84 | 102 |
103 IN_PROC_BROWSER_TEST_F(SyncFileSystemApiTest, OnFileSynced) { | |
104 // Mock a pending remote change to be synced. | |
105 GURL origin; | |
106 EXPECT_CALL(*mock_remote_service(), RegisterOriginForTrackingChanges(_, _)) | |
107 .WillOnce(UpdateRemoteChangeQueue(&origin, mock_remote_service())); | |
108 EXPECT_CALL(*mock_remote_service(), ProcessRemoteChange(_, _)) | |
109 .WillOnce(ProcessRemoteChangeAndCallBack(&origin, | |
110 mock_remote_service())); | |
111 ASSERT_TRUE(RunPlatformAppTest("sync_file_system/on_file_synced")) | |
112 << message_; | |
113 } | |
114 | |
85 IN_PROC_BROWSER_TEST_F(SyncFileSystemApiTest, OnSyncStateChanged) { | 115 IN_PROC_BROWSER_TEST_F(SyncFileSystemApiTest, OnSyncStateChanged) { |
86 EXPECT_CALL(*mock_remote_service(), | 116 EXPECT_CALL(*mock_remote_service(), RegisterOriginForTrackingChanges(_, _)) |
87 RegisterOriginForTrackingChanges(_, _)) | |
88 .WillOnce(NotifyOkStateAndCallback(mock_remote_service())); | 117 .WillOnce(NotifyOkStateAndCallback(mock_remote_service())); |
89 ASSERT_TRUE(RunPlatformAppTest("sync_file_system/on_sync_state_changed")) | 118 ASSERT_TRUE(RunPlatformAppTest("sync_file_system/on_sync_state_changed")) |
90 << message_; | 119 << message_; |
91 } | 120 } |
92 | 121 |
93 IN_PROC_BROWSER_TEST_F(SyncFileSystemApiTest, RequestFileSystem) { | 122 IN_PROC_BROWSER_TEST_F(SyncFileSystemApiTest, RequestFileSystem) { |
94 EXPECT_CALL(*mock_remote_service(), | 123 EXPECT_CALL(*mock_remote_service(), |
95 RegisterOriginForTrackingChanges(_, _)).Times(1); | 124 RegisterOriginForTrackingChanges(_, _)).Times(1); |
96 ASSERT_TRUE(RunPlatformAppTest("sync_file_system/request_file_system")) | 125 ASSERT_TRUE(RunPlatformAppTest("sync_file_system/request_file_system")) |
97 << message_; | 126 << message_; |
98 } | 127 } |
99 | 128 |
100 IN_PROC_BROWSER_TEST_F(SyncFileSystemApiTest, WriteFileThenGetUsage) { | 129 IN_PROC_BROWSER_TEST_F(SyncFileSystemApiTest, WriteFileThenGetUsage) { |
101 ASSERT_TRUE(RunPlatformAppTest("sync_file_system/write_file_then_get_usage")) | 130 ASSERT_TRUE(RunPlatformAppTest("sync_file_system/write_file_then_get_usage")) |
102 << message_; | 131 << message_; |
103 } | 132 } |
104 | 133 |
105 #endif // !defined(OS_CHROMEOS) | 134 #endif // !defined(OS_CHROMEOS) |
106 | 135 |
107 } // namespace chrome | 136 } // namespace chrome |
108 | 137 |
OLD | NEW |