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

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

Issue 184563006: Move WriteFile and WriteFileDescriptor from file_util to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/extensions/extension_service_unittest.h" 5 #include "chrome/browser/extensions/extension_service_unittest.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 2234 matching lines...) Expand 10 before | Expand all | Expand 10 after
2245 // Try packing an empty directory. Should fail because an empty directory is 2245 // Try packing an empty directory. Should fail because an empty directory is
2246 // not a valid extension. 2246 // not a valid extension.
2247 base::ScopedTempDir temp_dir2; 2247 base::ScopedTempDir temp_dir2;
2248 ASSERT_TRUE(temp_dir2.CreateUniqueTempDir()); 2248 ASSERT_TRUE(temp_dir2.CreateUniqueTempDir());
2249 creator.reset(new ExtensionCreator()); 2249 creator.reset(new ExtensionCreator());
2250 ASSERT_FALSE(creator->Run(temp_dir2.path(), crx_path, privkey_path, 2250 ASSERT_FALSE(creator->Run(temp_dir2.path(), crx_path, privkey_path,
2251 base::FilePath(), ExtensionCreator::kOverwriteCRX)); 2251 base::FilePath(), ExtensionCreator::kOverwriteCRX));
2252 2252
2253 // Try packing with an invalid manifest. 2253 // Try packing with an invalid manifest.
2254 std::string invalid_manifest_content = "I am not a manifest."; 2254 std::string invalid_manifest_content = "I am not a manifest.";
2255 ASSERT_TRUE(file_util::WriteFile( 2255 ASSERT_TRUE(base::WriteFile(
2256 temp_dir2.path().Append(extensions::kManifestFilename), 2256 temp_dir2.path().Append(extensions::kManifestFilename),
2257 invalid_manifest_content.c_str(), invalid_manifest_content.size())); 2257 invalid_manifest_content.c_str(), invalid_manifest_content.size()));
2258 creator.reset(new ExtensionCreator()); 2258 creator.reset(new ExtensionCreator());
2259 ASSERT_FALSE(creator->Run(temp_dir2.path(), crx_path, privkey_path, 2259 ASSERT_FALSE(creator->Run(temp_dir2.path(), crx_path, privkey_path,
2260 base::FilePath(), ExtensionCreator::kOverwriteCRX)); 2260 base::FilePath(), ExtensionCreator::kOverwriteCRX));
2261 2261
2262 // Try packing with a private key that is a valid key, but invalid for the 2262 // Try packing with a private key that is a valid key, but invalid for the
2263 // extension. 2263 // extension.
2264 base::FilePath bad_private_key_dir = data_dir_.AppendASCII("bad_private_key"); 2264 base::FilePath bad_private_key_dir = data_dir_.AppendASCII("bad_private_key");
2265 crx_path = output_directory.AppendASCII("bad_private_key.crx"); 2265 crx_path = output_directory.AppendASCII("bad_private_key.crx");
(...skipping 2183 matching lines...) Expand 10 before | Expand all | Expand 10 after
4449 EXPECT_EQ(origin_id, origins[0].GetOriginIdentifier()); 4449 EXPECT_EQ(origin_id, origins[0].GetOriginIdentifier());
4450 4450
4451 // Create local storage. We only simulate this by creating the backing files. 4451 // Create local storage. We only simulate this by creating the backing files.
4452 // Note: This test depends on details of how the dom_storage library 4452 // Note: This test depends on details of how the dom_storage library
4453 // stores data in the host file system. 4453 // stores data in the host file system.
4454 base::FilePath lso_dir_path = 4454 base::FilePath lso_dir_path =
4455 profile_->GetPath().AppendASCII("Local Storage"); 4455 profile_->GetPath().AppendASCII("Local Storage");
4456 base::FilePath lso_file_path = lso_dir_path.AppendASCII(origin_id) 4456 base::FilePath lso_file_path = lso_dir_path.AppendASCII(origin_id)
4457 .AddExtension(FILE_PATH_LITERAL(".localstorage")); 4457 .AddExtension(FILE_PATH_LITERAL(".localstorage"));
4458 EXPECT_TRUE(base::CreateDirectory(lso_dir_path)); 4458 EXPECT_TRUE(base::CreateDirectory(lso_dir_path));
4459 EXPECT_EQ(0, file_util::WriteFile(lso_file_path, NULL, 0)); 4459 EXPECT_EQ(0, base::WriteFile(lso_file_path, NULL, 0));
4460 EXPECT_TRUE(base::PathExists(lso_file_path)); 4460 EXPECT_TRUE(base::PathExists(lso_file_path));
4461 4461
4462 // Create indexed db. Similarly, it is enough to only simulate this by 4462 // Create indexed db. Similarly, it is enough to only simulate this by
4463 // creating the directory on the disk. 4463 // creating the directory on the disk.
4464 IndexedDBContext* idb_context = 4464 IndexedDBContext* idb_context =
4465 BrowserContext::GetDefaultStoragePartition(profile_.get())-> 4465 BrowserContext::GetDefaultStoragePartition(profile_.get())->
4466 GetIndexedDBContext(); 4466 GetIndexedDBContext();
4467 idb_context->SetTaskRunnerForTesting( 4467 idb_context->SetTaskRunnerForTesting(
4468 base::MessageLoop::current()->message_loop_proxy().get()); 4468 base::MessageLoop::current()->message_loop_proxy().get());
4469 base::FilePath idb_path = idb_context->GetFilePathForTesting(origin_id); 4469 base::FilePath idb_path = idb_context->GetFilePathForTesting(origin_id);
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
4565 EXPECT_EQ(origin_id, origins[0].GetOriginIdentifier()); 4565 EXPECT_EQ(origin_id, origins[0].GetOriginIdentifier());
4566 4566
4567 // Create local storage. We only simulate this by creating the backing files. 4567 // Create local storage. We only simulate this by creating the backing files.
4568 // Note: This test depends on details of how the dom_storage library 4568 // Note: This test depends on details of how the dom_storage library
4569 // stores data in the host file system. 4569 // stores data in the host file system.
4570 base::FilePath lso_dir_path = 4570 base::FilePath lso_dir_path =
4571 profile_->GetPath().AppendASCII("Local Storage"); 4571 profile_->GetPath().AppendASCII("Local Storage");
4572 base::FilePath lso_file_path = lso_dir_path.AppendASCII(origin_id) 4572 base::FilePath lso_file_path = lso_dir_path.AppendASCII(origin_id)
4573 .AddExtension(FILE_PATH_LITERAL(".localstorage")); 4573 .AddExtension(FILE_PATH_LITERAL(".localstorage"));
4574 EXPECT_TRUE(base::CreateDirectory(lso_dir_path)); 4574 EXPECT_TRUE(base::CreateDirectory(lso_dir_path));
4575 EXPECT_EQ(0, file_util::WriteFile(lso_file_path, NULL, 0)); 4575 EXPECT_EQ(0, base::WriteFile(lso_file_path, NULL, 0));
4576 EXPECT_TRUE(base::PathExists(lso_file_path)); 4576 EXPECT_TRUE(base::PathExists(lso_file_path));
4577 4577
4578 // Create indexed db. Similarly, it is enough to only simulate this by 4578 // Create indexed db. Similarly, it is enough to only simulate this by
4579 // creating the directory on the disk. 4579 // creating the directory on the disk.
4580 IndexedDBContext* idb_context = 4580 IndexedDBContext* idb_context =
4581 BrowserContext::GetDefaultStoragePartition(profile_.get())-> 4581 BrowserContext::GetDefaultStoragePartition(profile_.get())->
4582 GetIndexedDBContext(); 4582 GetIndexedDBContext();
4583 idb_context->SetTaskRunnerForTesting( 4583 idb_context->SetTaskRunnerForTesting(
4584 base::MessageLoop::current()->message_loop_proxy().get()); 4584 base::MessageLoop::current()->message_loop_proxy().get());
4585 base::FilePath idb_path = idb_context->GetFilePathForTesting(origin_id); 4585 base::FilePath idb_path = idb_context->GetFilePathForTesting(origin_id);
(...skipping 2362 matching lines...) Expand 10 before | Expand all | Expand 10 after
6948 // ReconcileKnownDisabled(). 6948 // ReconcileKnownDisabled().
6949 service_->EnableExtension(good2); 6949 service_->EnableExtension(good2);
6950 service_->ReconcileKnownDisabled(); 6950 service_->ReconcileKnownDisabled();
6951 expected_extensions.insert(good2); 6951 expected_extensions.insert(good2);
6952 expected_disabled_extensions.erase(good2); 6952 expected_disabled_extensions.erase(good2);
6953 6953
6954 EXPECT_EQ(expected_extensions, registry_->enabled_extensions().GetIDs()); 6954 EXPECT_EQ(expected_extensions, registry_->enabled_extensions().GetIDs());
6955 EXPECT_EQ(expected_disabled_extensions, 6955 EXPECT_EQ(expected_disabled_extensions,
6956 registry_->disabled_extensions().GetIDs()); 6956 registry_->disabled_extensions().GetIDs());
6957 } 6957 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_creator.cc ('k') | chrome/browser/extensions/sandboxed_unpacker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698