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

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 comment 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 23 matching lines...) Expand all
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(src,
42 extension_id, 42 extension_id,
43 version, 43 version,
44 all_extensions); 44 all_extensions,
45 true);
Robert Sesek 2012/02/09 18:43:59 /*should_delete=*/true); and on line 60
sail 2012/02/10 00:13:18 Done.
45 ASSERT_EQ(version_1.value(), 46 ASSERT_EQ(version_1.value(),
46 all_extensions.AppendASCII(extension_id).AppendASCII("1.0_0") 47 all_extensions.AppendASCII(extension_id).AppendASCII("1.0_0")
47 .value()); 48 .value());
48 ASSERT_TRUE(file_util::DirectoryExists(version_1)); 49 ASSERT_TRUE(file_util::DirectoryExists(version_1));
49 50
50 // Should have moved the source. 51 // Should have moved the source.
51 ASSERT_FALSE(file_util::DirectoryExists(src)); 52 ASSERT_FALSE(file_util::DirectoryExists(src));
52 53
53 // Install again. Should create a new one with different name. 54 // Install again. Should create a new one with different name.
54 ASSERT_TRUE(file_util::CreateDirectory(src)); 55 ASSERT_TRUE(file_util::CreateDirectory(src));
55 FilePath version_2 = extension_file_util::InstallExtension(src, 56 FilePath version_2 = extension_file_util::InstallExtension(src,
56 extension_id, 57 extension_id,
57 version, 58 version,
58 all_extensions); 59 all_extensions,
60 true);
59 ASSERT_EQ(version_2.value(), 61 ASSERT_EQ(version_2.value(),
60 all_extensions.AppendASCII(extension_id).AppendASCII("1.0_1") 62 all_extensions.AppendASCII(extension_id).AppendASCII("1.0_1")
61 .value()); 63 .value());
62 ASSERT_TRUE(file_util::DirectoryExists(version_2)); 64 ASSERT_TRUE(file_util::DirectoryExists(version_2));
63 65
64 // Collect garbage. Should remove first one. 66 // Collect garbage. Should remove first one.
65 std::map<std::string, FilePath> extension_paths; 67 std::map<std::string, FilePath> extension_paths;
66 extension_paths[extension_id] = 68 extension_paths[extension_id] =
67 FilePath().AppendASCII(extension_id).Append(version_2.BaseName()); 69 FilePath().AppendASCII(extension_id).Append(version_2.BaseName());
68 extension_file_util::GarbageCollectExtensions(all_extensions, 70 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)); 359 EXPECT_FALSE(extension_file_util::ValidateExtension(extension, &error));
358 EXPECT_EQ(l10n_util::GetStringFUTF8( 360 EXPECT_EQ(l10n_util::GetStringFUTF8(
359 IDS_EXTENSION_LOAD_BACKGROUND_SCRIPT_FAILED, 361 IDS_EXTENSION_LOAD_BACKGROUND_SCRIPT_FAILED,
360 ASCIIToUTF16("http://google.com/foo.js")), 362 ASCIIToUTF16("http://google.com/foo.js")),
361 error); 363 error);
362 } 364 }
363 365
364 // TODO(aa): More tests as motivation allows. Maybe steal some from 366 // TODO(aa): More tests as motivation allows. Maybe steal some from
365 // ExtensionService? Many of them could probably be tested here without the 367 // ExtensionService? Many of them could probably be tested here without the
366 // MessageLoop shenanigans. 368 // MessageLoop shenanigans.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698