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

Side by Side Diff: chrome/common/extensions/extension_file_util_unittest.cc

Issue 9374009: Install platform apps into a separate data directory (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix test Created 8 years, 10 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) 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/common/extensions/extension_file_util.h" 5 #include "chrome/common/extensions/extension_file_util.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/json/json_value_serializer.h" 8 #include "base/json/json_value_serializer.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "base/scoped_temp_dir.h" 10 #include "base/scoped_temp_dir.h"
(...skipping 20 matching lines...) Expand all
31 std::string extension_id("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); 31 std::string extension_id("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
32 std::string version("1.0"); 32 std::string version("1.0");
33 FilePath src = temp.path().AppendASCII(extension_id); 33 FilePath src = temp.path().AppendASCII(extension_id);
34 ASSERT_TRUE(file_util::CreateDirectory(src)); 34 ASSERT_TRUE(file_util::CreateDirectory(src));
35 35
36 // Create a extensions tree. 36 // Create a extensions tree.
37 FilePath all_extensions = temp.path().AppendASCII("extensions"); 37 FilePath all_extensions = temp.path().AppendASCII("extensions");
38 ASSERT_TRUE(file_util::CreateDirectory(all_extensions)); 38 ASSERT_TRUE(file_util::CreateDirectory(all_extensions));
39 39
40 // Install in empty directory. Should create parent directories as needed. 40 // Install in empty directory. Should create parent directories as needed.
41 FilePath version_1 = extension_file_util::InstallExtension(src, 41 FilePath version_1 = extension_file_util::InstallExtension(
42 extension_id, 42 src,
jeremy 2012/02/12 09:40:28 IMHO this should be indented 4 from the start of t
43 version, 43 extension_id,
44 all_extensions); 44 version,
45 all_extensions,
46 extension_file_util::DELETE_SOURCE_YES);
45 ASSERT_EQ(version_1.value(), 47 ASSERT_EQ(version_1.value(),
46 all_extensions.AppendASCII(extension_id).AppendASCII("1.0_0") 48 all_extensions.AppendASCII(extension_id).AppendASCII("1.0_0")
47 .value()); 49 .value());
48 ASSERT_TRUE(file_util::DirectoryExists(version_1)); 50 ASSERT_TRUE(file_util::DirectoryExists(version_1));
49 51
50 // Should have moved the source. 52 // Should have moved the source.
51 ASSERT_FALSE(file_util::DirectoryExists(src)); 53 ASSERT_FALSE(file_util::DirectoryExists(src));
52 54
53 // Install again. Should create a new one with different name. 55 // Install again. Should create a new one with different name.
54 ASSERT_TRUE(file_util::CreateDirectory(src)); 56 ASSERT_TRUE(file_util::CreateDirectory(src));
55 FilePath version_2 = extension_file_util::InstallExtension(src, 57 FilePath version_2 = extension_file_util::InstallExtension(
56 extension_id, 58 src,
57 version, 59 extension_id,
58 all_extensions); 60 version,
61 all_extensions,
62 extension_file_util::DELETE_SOURCE_YES);
59 ASSERT_EQ(version_2.value(), 63 ASSERT_EQ(version_2.value(),
60 all_extensions.AppendASCII(extension_id).AppendASCII("1.0_1") 64 all_extensions.AppendASCII(extension_id).AppendASCII("1.0_1")
61 .value()); 65 .value());
62 ASSERT_TRUE(file_util::DirectoryExists(version_2)); 66 ASSERT_TRUE(file_util::DirectoryExists(version_2));
63 67
64 // Collect garbage. Should remove first one. 68 // Collect garbage. Should remove first one.
65 std::map<std::string, FilePath> extension_paths; 69 std::map<std::string, FilePath> extension_paths;
66 extension_paths[extension_id] = 70 extension_paths[extension_id] =
67 FilePath().AppendASCII(extension_id).Append(version_2.BaseName()); 71 FilePath().AppendASCII(extension_id).Append(version_2.BaseName());
68 extension_file_util::GarbageCollectExtensions(all_extensions, 72 extension_file_util::GarbageCollectExtensions(all_extensions,
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 EXPECT_FALSE(extension_file_util::ValidateExtension(extension, &error)); 361 EXPECT_FALSE(extension_file_util::ValidateExtension(extension, &error));
358 EXPECT_EQ(l10n_util::GetStringFUTF8( 362 EXPECT_EQ(l10n_util::GetStringFUTF8(
359 IDS_EXTENSION_LOAD_BACKGROUND_SCRIPT_FAILED, 363 IDS_EXTENSION_LOAD_BACKGROUND_SCRIPT_FAILED,
360 ASCIIToUTF16("http://google.com/foo.js")), 364 ASCIIToUTF16("http://google.com/foo.js")),
361 error); 365 error);
362 } 366 }
363 367
364 // TODO(aa): More tests as motivation allows. Maybe steal some from 368 // TODO(aa): More tests as motivation allows. Maybe steal some from
365 // ExtensionService? Many of them could probably be tested here without the 369 // ExtensionService? Many of them could probably be tested here without the
366 // MessageLoop shenanigans. 370 // MessageLoop shenanigans.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698