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 "chrome/browser/sync_file_system/drive_file_sync_service.h" | 5 #include "chrome/browser/sync_file_system/drive_file_sync_service.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
11 #include "base/message_loop_proxy.h" | 11 #include "base/message_loop_proxy.h" |
12 #include "chrome/browser/extensions/test_extension_service.h" | 12 #include "chrome/browser/extensions/test_extension_service.h" |
13 #include "chrome/browser/extensions/test_extension_system.h" | 13 #include "chrome/browser/extensions/test_extension_system.h" |
14 #include "chrome/browser/google_apis/drive_api_parser.h" | 14 #include "chrome/browser/google_apis/drive_api_parser.h" |
15 #include "chrome/browser/google_apis/drive_uploader.h" | 15 #include "chrome/browser/google_apis/drive_uploader.h" |
16 #include "chrome/browser/google_apis/gdata_errorcode.h" | 16 #include "chrome/browser/google_apis/gdata_errorcode.h" |
17 #include "chrome/browser/google_apis/gdata_wapi_parser.h" | 17 #include "chrome/browser/google_apis/gdata_wapi_parser.h" |
18 #include "chrome/browser/google_apis/mock_drive_service.h" | 18 #include "chrome/browser/google_apis/mock_drive_service.h" |
19 #include "chrome/browser/google_apis/test_util.h" | 19 #include "chrome/browser/google_apis/test_util.h" |
20 #include "chrome/browser/sync_file_system/drive_file_sync_client.h" | 20 #include "chrome/browser/sync_file_system/drive_file_sync_client.h" |
21 #include "chrome/browser/sync_file_system/drive_metadata_store.h" | 21 #include "chrome/browser/sync_file_system/drive_metadata_store.h" |
22 #include "chrome/browser/sync_file_system/file_status_observer.h" | 22 #include "chrome/browser/sync_file_system/file_status_observer.h" |
23 #include "chrome/browser/sync_file_system/mock_remote_change_processor.h" | 23 #include "chrome/browser/sync_file_system/mock_remote_change_processor.h" |
24 #include "chrome/browser/sync_file_system/sync_file_system.pb.h" | 24 #include "chrome/browser/sync_file_system/sync_file_system.pb.h" |
25 #include "chrome/common/extensions/extension.h" | 25 #include "chrome/common/extensions/extension.h" |
26 #include "chrome/common/extensions/extension_builder.h" | 26 #include "chrome/common/extensions/extension_builder.h" |
27 #include "chrome/test/base/testing_profile.h" | 27 #include "chrome/test/base/testing_profile.h" |
28 #include "content/public/test/test_browser_thread.h" | 28 #include "content/public/test/test_browser_thread.h" |
| 29 #include "extensions/common/id_util.h" |
29 #include "net/base/escape.h" | 30 #include "net/base/escape.h" |
30 #include "testing/gmock/include/gmock/gmock.h" | 31 #include "testing/gmock/include/gmock/gmock.h" |
31 #include "testing/gtest/include/gtest/gtest.h" | 32 #include "testing/gtest/include/gtest/gtest.h" |
32 #include "webkit/fileapi/syncable/sync_direction.h" | 33 #include "webkit/fileapi/syncable/sync_direction.h" |
33 #include "webkit/fileapi/syncable/sync_file_metadata.h" | 34 #include "webkit/fileapi/syncable/sync_file_metadata.h" |
34 #include "webkit/fileapi/syncable/syncable_file_system_util.h" | 35 #include "webkit/fileapi/syncable/syncable_file_system_util.h" |
35 | 36 |
36 #define FPL(x) FILE_PATH_LITERAL(x) | 37 #define FPL(x) FILE_PATH_LITERAL(x) |
37 | 38 |
38 using ::testing::AnyNumber; | 39 using ::testing::AnyNumber; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 SyncStatusCode actual) { | 81 SyncStatusCode actual) { |
81 EXPECT_FALSE(*done); | 82 EXPECT_FALSE(*done); |
82 *done = true; | 83 *done = true; |
83 EXPECT_EQ(expected, actual); | 84 EXPECT_EQ(expected, actual); |
84 } | 85 } |
85 | 86 |
86 // Mocks adding an installed extension to ExtensionService. | 87 // Mocks adding an installed extension to ExtensionService. |
87 scoped_refptr<const extensions::Extension> AddTestExtension( | 88 scoped_refptr<const extensions::Extension> AddTestExtension( |
88 ExtensionService* extension_service, | 89 ExtensionService* extension_service, |
89 const base::FilePath::StringType& extension_name) { | 90 const base::FilePath::StringType& extension_name) { |
90 std::string id = Extension::GenerateIdForPath(base::FilePath(extension_name)); | 91 std::string id = extensions::id_util::GenerateIdForPath( |
| 92 base::FilePath(extension_name)); |
91 | 93 |
92 scoped_refptr<const Extension> extension = | 94 scoped_refptr<const Extension> extension = |
93 extensions::ExtensionBuilder().SetManifest( | 95 extensions::ExtensionBuilder().SetManifest( |
94 DictionaryBuilder() | 96 DictionaryBuilder() |
95 .Set("name", extension_name) | 97 .Set("name", extension_name) |
96 .Set("version", "1.0")) | 98 .Set("version", "1.0")) |
97 .SetID(id) | 99 .SetID(id) |
98 .Build(); | 100 .Build(); |
99 extension_service->AddExtension(extension); | 101 extension_service->AddExtension(extension); |
100 return extension; | 102 return extension; |
101 } | 103 } |
102 | 104 |
103 // Converts extension_name to GURL version. | 105 // Converts extension_name to GURL version. |
104 GURL ExtensionNameToGURL(const base::FilePath::StringType& extension_name) { | 106 GURL ExtensionNameToGURL(const base::FilePath::StringType& extension_name) { |
105 std::string id = Extension::GenerateIdForPath(base::FilePath(extension_name)); | 107 std::string id = extensions::id_util::GenerateIdForPath( |
| 108 base::FilePath(extension_name)); |
106 return extensions::Extension::GetBaseURLFromExtensionId(id); | 109 return extensions::Extension::GetBaseURLFromExtensionId(id); |
107 } | 110 } |
108 | 111 |
109 ACTION(InvokeCompletionCallback) { | 112 ACTION(InvokeCompletionCallback) { |
110 base::MessageLoopProxy::current()->PostTask(FROM_HERE, arg1); | 113 base::MessageLoopProxy::current()->PostTask(FROM_HERE, arg1); |
111 } | 114 } |
112 | 115 |
113 // Invokes |arg0| as a GetDataCallback. | 116 // Invokes |arg0| as a GetDataCallback. |
114 ACTION_P2(InvokeGetAboutResourceCallback0, error, result) { | 117 ACTION_P2(InvokeGetAboutResourceCallback0, error, result) { |
115 scoped_ptr<google_apis::AboutResource> about_resource(result.Pass()); | 118 scoped_ptr<google_apis::AboutResource> about_resource(result.Pass()); |
(...skipping 999 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1115 entry->set_kind(google_apis::ENTRY_KIND_FOLDER); | 1118 entry->set_kind(google_apis::ENTRY_KIND_FOLDER); |
1116 | 1119 |
1117 // Expect to drop this change for file. | 1120 // Expect to drop this change for file. |
1118 EXPECT_FALSE(AppendIncrementalRemoteChangeByEntry( | 1121 EXPECT_FALSE(AppendIncrementalRemoteChangeByEntry( |
1119 kOrigin, *entry, 1)); | 1122 kOrigin, *entry, 1)); |
1120 } | 1123 } |
1121 | 1124 |
1122 #endif // !defined(OS_ANDROID) | 1125 #endif // !defined(OS_ANDROID) |
1123 | 1126 |
1124 } // namespace sync_file_system | 1127 } // namespace sync_file_system |
OLD | NEW |