OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_backend/sync_engine.h" | 5 #include "chrome/browser/sync_file_system/drive_backend/sync_engine.h" |
6 | 6 |
7 #include "base/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" |
8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "chrome/browser/drive/drive_uploader.h" | 10 #include "chrome/browser/drive/drive_uploader.h" |
11 #include "chrome/browser/drive/fake_drive_service.h" | 11 #include "chrome/browser/drive/fake_drive_service.h" |
12 #include "chrome/browser/extensions/test_extension_service.h" | 12 #include "chrome/browser/extensions/test_extension_service.h" |
13 #include "chrome/browser/sync_file_system/drive_backend/metadata_database.h" | 13 #include "chrome/browser/sync_file_system/drive_backend/metadata_database.h" |
14 #include "chrome/browser/sync_file_system/drive_backend/metadata_database.pb.h" | 14 #include "chrome/browser/sync_file_system/drive_backend/metadata_database.pb.h" |
15 #include "chrome/browser/sync_file_system/sync_file_system_test_util.h" | 15 #include "chrome/browser/sync_file_system/sync_file_system_test_util.h" |
16 #include "content/public/test/test_browser_thread_bundle.h" | 16 #include "content/public/test/test_browser_thread_bundle.h" |
17 #include "extensions/common/extension.h" | 17 #include "extensions/common/extension.h" |
18 #include "extensions/common/extension_builder.h" | 18 #include "extensions/common/extension_builder.h" |
| 19 #include "extensions/common/extension_set.h" |
19 #include "extensions/common/value_builder.h" | 20 #include "extensions/common/value_builder.h" |
20 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
21 | 22 |
22 namespace sync_file_system { | 23 namespace sync_file_system { |
23 namespace drive_backend { | 24 namespace drive_backend { |
24 | 25 |
25 namespace { | 26 namespace { |
26 | 27 |
27 const char kAppID[] = "app_id"; | 28 const char kAppID[] = "app_id"; |
28 | 29 |
(...skipping 17 matching lines...) Expand all Loading... |
46 | 47 |
47 private: | 48 private: |
48 DISALLOW_COPY_AND_ASSIGN(MockSyncTask); | 49 DISALLOW_COPY_AND_ASSIGN(MockSyncTask); |
49 }; | 50 }; |
50 | 51 |
51 class MockExtensionService : public TestExtensionService { | 52 class MockExtensionService : public TestExtensionService { |
52 public: | 53 public: |
53 MockExtensionService() {} | 54 MockExtensionService() {} |
54 virtual ~MockExtensionService() {} | 55 virtual ~MockExtensionService() {} |
55 | 56 |
56 virtual const ExtensionSet* extensions() const OVERRIDE { | 57 virtual const extensions::ExtensionSet* extensions() const OVERRIDE { |
57 return &extensions_; | 58 return &extensions_; |
58 } | 59 } |
59 | 60 |
60 virtual const ExtensionSet* disabled_extensions() const OVERRIDE { | 61 virtual const extensions::ExtensionSet* disabled_extensions() const OVERRIDE { |
61 return &disabled_extensions_; | 62 return &disabled_extensions_; |
62 } | 63 } |
63 | 64 |
64 virtual void AddExtension(const extensions::Extension* extension) OVERRIDE { | 65 virtual void AddExtension(const extensions::Extension* extension) OVERRIDE { |
65 extensions_.Insert(make_scoped_refptr(extension)); | 66 extensions_.Insert(make_scoped_refptr(extension)); |
66 } | 67 } |
67 | 68 |
68 virtual const extensions::Extension* GetInstalledExtension( | 69 virtual const extensions::Extension* GetInstalledExtension( |
69 const std::string& extension_id) const OVERRIDE { | 70 const std::string& extension_id) const OVERRIDE { |
70 return extensions_.GetByID(extension_id); | 71 return extensions_.GetByID(extension_id); |
(...skipping 11 matching lines...) Expand all Loading... |
82 } | 83 } |
83 | 84 |
84 void DisableExtension(const std::string& extension_id) { | 85 void DisableExtension(const std::string& extension_id) { |
85 if (!IsExtensionEnabled(extension_id)) | 86 if (!IsExtensionEnabled(extension_id)) |
86 return; | 87 return; |
87 const extensions::Extension* extension = extensions_.GetByID(extension_id); | 88 const extensions::Extension* extension = extensions_.GetByID(extension_id); |
88 disabled_extensions_.Insert(make_scoped_refptr(extension)); | 89 disabled_extensions_.Insert(make_scoped_refptr(extension)); |
89 } | 90 } |
90 | 91 |
91 private: | 92 private: |
92 ExtensionSet extensions_; | 93 extensions::ExtensionSet extensions_; |
93 ExtensionSet disabled_extensions_; | 94 extensions::ExtensionSet disabled_extensions_; |
94 | 95 |
95 DISALLOW_COPY_AND_ASSIGN(MockExtensionService); | 96 DISALLOW_COPY_AND_ASSIGN(MockExtensionService); |
96 }; | 97 }; |
97 | 98 |
98 class SyncEngineTest | 99 class SyncEngineTest |
99 : public testing::Test, | 100 : public testing::Test, |
100 public base::SupportsWeakPtr<SyncEngineTest> { | 101 public base::SupportsWeakPtr<SyncEngineTest> { |
101 public: | 102 public: |
102 SyncEngineTest() {} | 103 SyncEngineTest() {} |
103 virtual ~SyncEngineTest() {} | 104 virtual ~SyncEngineTest() {} |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 base::Bind(&SyncEngineTest::CheckServiceState, | 349 base::Bind(&SyncEngineTest::CheckServiceState, |
349 AsWeakPtr(), | 350 AsWeakPtr(), |
350 SYNC_STATUS_OK, | 351 SYNC_STATUS_OK, |
351 REMOTE_SERVICE_OK)); | 352 REMOTE_SERVICE_OK)); |
352 | 353 |
353 base::RunLoop().RunUntilIdle(); | 354 base::RunLoop().RunUntilIdle(); |
354 } | 355 } |
355 | 356 |
356 } // namespace drive_backend | 357 } // namespace drive_backend |
357 } // namespace sync_file_system | 358 } // namespace sync_file_system |
OLD | NEW |