| 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 <stdint.h> | 5 #include <stdint.h> |
| 6 | 6 |
| 7 #include "base/auto_reset.h" |
| 7 #include "base/bind.h" | 8 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 9 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| 10 #include "base/threading/thread_task_runner_handle.h" | 11 #include "base/threading/thread_task_runner_handle.h" |
| 11 #include "chrome/browser/extensions/extension_apitest.h" | 12 #include "chrome/browser/extensions/extension_apitest.h" |
| 12 #include "chrome/browser/sync_file_system/file_status_observer.h" | 13 #include "chrome/browser/sync_file_system/file_status_observer.h" |
| 13 #include "chrome/browser/sync_file_system/local_change_processor.h" | 14 #include "chrome/browser/sync_file_system/local_change_processor.h" |
| 14 #include "chrome/browser/sync_file_system/mock_remote_file_sync_service.h" | 15 #include "chrome/browser/sync_file_system/mock_remote_file_sync_service.h" |
| 15 #include "chrome/browser/sync_file_system/sync_file_system_service.h" | 16 #include "chrome/browser/sync_file_system/sync_file_system_service.h" |
| 16 #include "chrome/browser/sync_file_system/sync_file_system_service_factory.h" | 17 #include "chrome/browser/sync_file_system/sync_file_system_service_factory.h" |
| 17 #include "chrome/browser/sync_file_system/sync_status_code.h" | 18 #include "chrome/browser/sync_file_system/sync_status_code.h" |
| 18 #include "chrome/browser/sync_file_system/syncable_file_system_util.h" | 19 #include "chrome/browser/sync_file_system/syncable_file_system_util.h" |
| 19 #include "chrome/test/base/test_switches.h" | 20 #include "chrome/test/base/test_switches.h" |
| 21 #include "extensions/browser/extension_function.h" |
| 20 #include "storage/browser/fileapi/file_system_url.h" | 22 #include "storage/browser/fileapi/file_system_url.h" |
| 21 #include "storage/browser/quota/quota_manager.h" | 23 #include "storage/browser/quota/quota_manager.h" |
| 22 #include "testing/gmock/include/gmock/gmock.h" | 24 #include "testing/gmock/include/gmock/gmock.h" |
| 23 #include "testing/gtest/include/gtest/gtest.h" | 25 #include "testing/gtest/include/gtest/gtest.h" |
| 24 | 26 |
| 25 using ::testing::_; | 27 using ::testing::_; |
| 26 using ::testing::Eq; | 28 using ::testing::Eq; |
| 27 using ::testing::Ne; | 29 using ::testing::Ne; |
| 28 using ::testing::Property; | 30 using ::testing::Property; |
| 29 using ::testing::Return; | 31 using ::testing::Return; |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 << message_; | 136 << message_; |
| 135 } | 137 } |
| 136 | 138 |
| 137 IN_PROC_BROWSER_TEST_F(SyncFileSystemApiTest, GetUsageAndQuota) { | 139 IN_PROC_BROWSER_TEST_F(SyncFileSystemApiTest, GetUsageAndQuota) { |
| 138 ASSERT_TRUE(RunExtensionTest("sync_file_system/get_usage_and_quota")) | 140 ASSERT_TRUE(RunExtensionTest("sync_file_system/get_usage_and_quota")) |
| 139 << message_; | 141 << message_; |
| 140 } | 142 } |
| 141 | 143 |
| 142 IN_PROC_BROWSER_TEST_F(SyncFileSystemApiTest, OnFileStatusChanged) { | 144 IN_PROC_BROWSER_TEST_F(SyncFileSystemApiTest, OnFileStatusChanged) { |
| 143 // Mock a pending remote change to be synced. | 145 // Mock a pending remote change to be synced. |
| 146 // We ignore the did_respond trait on ExtensionFunction because we mock out |
| 147 // the service, which results in the callback never being called. Yuck. |
| 148 base::AutoReset<bool> ignore_did_respond( |
| 149 &ExtensionFunction::ignore_all_did_respond_for_testing_do_not_use, true); |
| 144 GURL origin; | 150 GURL origin; |
| 145 EXPECT_CALL(*mock_remote_service(), RegisterOrigin(_, _)) | 151 EXPECT_CALL(*mock_remote_service(), RegisterOrigin(_, _)) |
| 146 .WillOnce(UpdateRemoteChangeQueue(&origin, mock_remote_service())); | 152 .WillOnce(UpdateRemoteChangeQueue(&origin, mock_remote_service())); |
| 147 EXPECT_CALL(*mock_remote_service(), ProcessRemoteChange(_)) | 153 EXPECT_CALL(*mock_remote_service(), ProcessRemoteChange(_)) |
| 148 .WillOnce(ReturnWithFakeFileAddedStatus( | 154 .WillOnce(ReturnWithFakeFileAddedStatus( |
| 149 &origin, | 155 &origin, |
| 150 mock_remote_service(), | 156 mock_remote_service(), |
| 151 sync_file_system::SYNC_FILE_TYPE_FILE, | 157 sync_file_system::SYNC_FILE_TYPE_FILE, |
| 152 sync_file_system::SYNC_FILE_STATUS_SYNCED, | 158 sync_file_system::SYNC_FILE_STATUS_SYNCED, |
| 153 sync_file_system::SYNC_ACTION_ADDED, | 159 sync_file_system::SYNC_ACTION_ADDED, |
| 154 sync_file_system::SYNC_DIRECTION_REMOTE_TO_LOCAL)); | 160 sync_file_system::SYNC_DIRECTION_REMOTE_TO_LOCAL)); |
| 155 ASSERT_TRUE(RunPlatformAppTest("sync_file_system/on_file_status_changed")) | 161 ASSERT_TRUE(RunPlatformAppTest("sync_file_system/on_file_status_changed")) |
| 156 << message_; | 162 << message_; |
| 157 } | 163 } |
| 158 | 164 |
| 159 IN_PROC_BROWSER_TEST_F(SyncFileSystemApiTest, OnFileStatusChangedDeleted) { | 165 IN_PROC_BROWSER_TEST_F(SyncFileSystemApiTest, OnFileStatusChangedDeleted) { |
| 160 // Mock a pending remote change to be synced. | 166 // Mock a pending remote change to be synced. |
| 167 // We ignore the did_respond trait on ExtensionFunction because we mock out |
| 168 // the service, which results in the callback never being called. Yuck. |
| 169 base::AutoReset<bool> ignore_did_respond( |
| 170 &ExtensionFunction::ignore_all_did_respond_for_testing_do_not_use, true); |
| 161 GURL origin; | 171 GURL origin; |
| 162 EXPECT_CALL(*mock_remote_service(), RegisterOrigin(_, _)) | 172 EXPECT_CALL(*mock_remote_service(), RegisterOrigin(_, _)) |
| 163 .WillOnce(UpdateRemoteChangeQueue(&origin, mock_remote_service())); | 173 .WillOnce(UpdateRemoteChangeQueue(&origin, mock_remote_service())); |
| 164 EXPECT_CALL(*mock_remote_service(), ProcessRemoteChange(_)) | 174 EXPECT_CALL(*mock_remote_service(), ProcessRemoteChange(_)) |
| 165 .WillOnce(ReturnWithFakeFileAddedStatus( | 175 .WillOnce(ReturnWithFakeFileAddedStatus( |
| 166 &origin, | 176 &origin, |
| 167 mock_remote_service(), | 177 mock_remote_service(), |
| 168 sync_file_system::SYNC_FILE_TYPE_FILE, | 178 sync_file_system::SYNC_FILE_TYPE_FILE, |
| 169 sync_file_system::SYNC_FILE_STATUS_SYNCED, | 179 sync_file_system::SYNC_FILE_STATUS_SYNCED, |
| 170 sync_file_system::SYNC_ACTION_DELETED, | 180 sync_file_system::SYNC_ACTION_DELETED, |
| (...skipping 25 matching lines...) Expand all Loading... |
| 196 ASSERT_TRUE(RunPlatformAppTest("sync_file_system/conflict_resolution_policy")) | 206 ASSERT_TRUE(RunPlatformAppTest("sync_file_system/conflict_resolution_policy")) |
| 197 << message_; | 207 << message_; |
| 198 } | 208 } |
| 199 | 209 |
| 200 IN_PROC_BROWSER_TEST_F(SyncFileSystemApiTest, GetServiceStatus) { | 210 IN_PROC_BROWSER_TEST_F(SyncFileSystemApiTest, GetServiceStatus) { |
| 201 mock_remote_service()->SetServiceState( | 211 mock_remote_service()->SetServiceState( |
| 202 sync_file_system::REMOTE_SERVICE_AUTHENTICATION_REQUIRED); | 212 sync_file_system::REMOTE_SERVICE_AUTHENTICATION_REQUIRED); |
| 203 ASSERT_TRUE(RunPlatformAppTest("sync_file_system/get_service_status")) | 213 ASSERT_TRUE(RunPlatformAppTest("sync_file_system/get_service_status")) |
| 204 << message_; | 214 << message_; |
| 205 } | 215 } |
| OLD | NEW |