Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(175)

Side by Side Diff: chrome/browser/extensions/app_data_migrator_unittest.cc

Issue 1871713002: Convert //chrome/browser/extensions from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and fix header Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/callback_forward.h" 10 #include "base/callback_forward.h"
11 #include "base/threading/sequenced_worker_pool.h" 11 #include "base/threading/sequenced_worker_pool.h"
12 #include "chrome/browser/extensions/app_data_migrator.h" 12 #include "chrome/browser/extensions/app_data_migrator.h"
13 #include "chrome/browser/extensions/extension_special_storage_policy.h" 13 #include "chrome/browser/extensions/extension_special_storage_policy.h"
14 #include "chrome/test/base/testing_profile.h" 14 #include "chrome/test/base/testing_profile.h"
15 #include "content/public/browser/browser_thread.h" 15 #include "content/public/browser/browser_thread.h"
16 #include "content/public/browser/indexed_db_context.h" 16 #include "content/public/browser/indexed_db_context.h"
17 #include "content/public/browser/storage_partition.h" 17 #include "content/public/browser/storage_partition.h"
18 #include "content/public/test/mock_blob_url_request_context.h" 18 #include "content/public/test/mock_blob_url_request_context.h"
19 #include "content/public/test/test_browser_thread_bundle.h" 19 #include "content/public/test/test_browser_thread_bundle.h"
20 #include "extensions/browser/extension_registry.h" 20 #include "extensions/browser/extension_registry.h"
21 #include "extensions/common/extension.h" 21 #include "extensions/common/extension.h"
22 #include "extensions/common/extension_builder.h" 22 #include "extensions/common/extension_builder.h"
23 #include "extensions/common/manifest.h" 23 #include "extensions/common/manifest.h"
24 #include "storage/browser/fileapi/file_system_context.h" 24 #include "storage/browser/fileapi/file_system_context.h"
25 #include "storage/browser/fileapi/file_system_operation_runner.h" 25 #include "storage/browser/fileapi/file_system_operation_runner.h"
26 #include "storage/browser/fileapi/file_system_url.h" 26 #include "storage/browser/fileapi/file_system_url.h"
27 #include "testing/gtest/include/gtest/gtest.h" 27 #include "testing/gtest/include/gtest/gtest.h"
28 28
29 namespace { 29 namespace {
30 scoped_ptr<TestingProfile> GetTestingProfile() { 30 std::unique_ptr<TestingProfile> GetTestingProfile() {
31 TestingProfile::Builder profile_builder; 31 TestingProfile::Builder profile_builder;
32 return profile_builder.Build(); 32 return profile_builder.Build();
33 } 33 }
34 } 34 }
35 35
36 namespace extensions { 36 namespace extensions {
37 37
38 class AppDataMigratorTest : public testing::Test { 38 class AppDataMigratorTest : public testing::Test {
39 public: 39 public:
40 AppDataMigratorTest() 40 AppDataMigratorTest()
41 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP) {} 41 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP) {}
42 42
43 void SetUp() override { 43 void SetUp() override {
44 profile_ = GetTestingProfile(); 44 profile_ = GetTestingProfile();
45 registry_ = ExtensionRegistry::Get(profile_.get()); 45 registry_ = ExtensionRegistry::Get(profile_.get());
46 migrator_ = scoped_ptr<AppDataMigrator>( 46 migrator_ = std::unique_ptr<AppDataMigrator>(
47 new AppDataMigrator(profile_.get(), registry_)); 47 new AppDataMigrator(profile_.get(), registry_));
48 48
49 default_partition_ = 49 default_partition_ =
50 content::BrowserContext::GetDefaultStoragePartition(profile_.get()); 50 content::BrowserContext::GetDefaultStoragePartition(profile_.get());
51 51
52 idb_context_ = default_partition_->GetIndexedDBContext(); 52 idb_context_ = default_partition_->GetIndexedDBContext();
53 idb_context_->SetTaskRunnerForTesting( 53 idb_context_->SetTaskRunnerForTesting(
54 base::MessageLoop::current()->task_runner().get()); 54 base::MessageLoop::current()->task_runner().get());
55 55
56 default_fs_context_ = default_partition_->GetFileSystemContext(); 56 default_fs_context_ = default_partition_->GetFileSystemContext();
57 57
58 url_request_context_ = scoped_ptr<content::MockBlobURLRequestContext>( 58 url_request_context_ = std::unique_ptr<content::MockBlobURLRequestContext>(
59 new content::MockBlobURLRequestContext(default_fs_context_)); 59 new content::MockBlobURLRequestContext(default_fs_context_));
60 } 60 }
61 61
62 void TearDown() override {} 62 void TearDown() override {}
63 63
64 protected: 64 protected:
65 content::TestBrowserThreadBundle thread_bundle_; 65 content::TestBrowserThreadBundle thread_bundle_;
66 scoped_ptr<TestingProfile> profile_; 66 std::unique_ptr<TestingProfile> profile_;
67 scoped_ptr<AppDataMigrator> migrator_; 67 std::unique_ptr<AppDataMigrator> migrator_;
68 content::StoragePartition* default_partition_; 68 content::StoragePartition* default_partition_;
69 ExtensionRegistry* registry_; 69 ExtensionRegistry* registry_;
70 storage::FileSystemContext* default_fs_context_; 70 storage::FileSystemContext* default_fs_context_;
71 content::IndexedDBContext* idb_context_; 71 content::IndexedDBContext* idb_context_;
72 scoped_ptr<content::MockBlobURLRequestContext> url_request_context_; 72 std::unique_ptr<content::MockBlobURLRequestContext> url_request_context_;
73 }; 73 };
74 74
75 scoped_refptr<const Extension> GetTestExtension(bool platform_app) { 75 scoped_refptr<const Extension> GetTestExtension(bool platform_app) {
76 scoped_refptr<const Extension> app; 76 scoped_refptr<const Extension> app;
77 if (platform_app) { 77 if (platform_app) {
78 app = ExtensionBuilder() 78 app = ExtensionBuilder()
79 .SetManifest( 79 .SetManifest(
80 DictionaryBuilder() 80 DictionaryBuilder()
81 .Set("name", "test app") 81 .Set("name", "test app")
82 .Set("version", "1") 82 .Set("version", "1")
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 base::MessageLoop::current()->Run(); 176 base::MessageLoop::current()->Run();
177 fs_context->operation_runner()->Write(url_request_context, fs_persistent_url, 177 fs_context->operation_runner()->Write(url_request_context, fs_persistent_url,
178 blob1.GetBlobDataHandle(), 0, 178 blob1.GetBlobDataHandle(), 0,
179 base::Bind(&DidWrite)); 179 base::Bind(&DidWrite));
180 base::MessageLoop::current()->Run(); 180 base::MessageLoop::current()->Run();
181 } 181 }
182 182
183 void VerifyFileContents(base::File file, 183 void VerifyFileContents(base::File file,
184 const base::Closure& on_close_callback) { 184 const base::Closure& on_close_callback) {
185 ASSERT_EQ(14, file.GetLength()); 185 ASSERT_EQ(14, file.GetLength());
186 scoped_ptr<char[]> buffer(new char[15]); 186 std::unique_ptr<char[]> buffer(new char[15]);
187 187
188 file.Read(0, buffer.get(), 14); 188 file.Read(0, buffer.get(), 14);
189 buffer.get()[14] = 0; 189 buffer.get()[14] = 0;
190 190
191 std::string expected = "Hello, world!\n"; 191 std::string expected = "Hello, world!\n";
192 std::string actual = buffer.get(); 192 std::string actual = buffer.get();
193 EXPECT_EQ(expected, actual); 193 EXPECT_EQ(expected, actual);
194 194
195 file.Close(); 195 file.Close();
196 if (!on_close_callback.is_null()) 196 if (!on_close_callback.is_null())
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 content::StoragePartition* new_partition = 275 content::StoragePartition* new_partition =
276 content::BrowserContext::GetStoragePartitionForSite(profile_.get(), 276 content::BrowserContext::GetStoragePartitionForSite(profile_.get(),
277 extension_url); 277 extension_url);
278 278
279 ASSERT_NE(new_partition->GetPath(), default_partition_->GetPath()); 279 ASSERT_NE(new_partition->GetPath(), default_partition_->GetPath());
280 280
281 VerifyTestFilesMigrated(new_partition, new_ext.get()); 281 VerifyTestFilesMigrated(new_partition, new_ext.get());
282 } 282 }
283 283
284 } // namespace extensions 284 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/app_data_migrator.cc ('k') | chrome/browser/extensions/background_app_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698