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

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

Issue 14694010: Consolidate manifest handler registration. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 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 "base/file_util.h" 5 #include "base/file_util.h"
6 #include "base/files/scoped_temp_dir.h" 6 #include "base/files/scoped_temp_dir.h"
7 #include "base/memory/ref_counted.h" 7 #include "base/memory/ref_counted.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "chrome/browser/extensions/sandboxed_unpacker.h" 12 #include "chrome/browser/extensions/sandboxed_unpacker.h"
13 #include "chrome/common/chrome_paths.h" 13 #include "chrome/common/chrome_paths.h"
14 #include "chrome/common/extensions/api/i18n/default_locale_handler.h"
15 #include "chrome/common/extensions/extension.h" 14 #include "chrome/common/extensions/extension.h"
16 #include "chrome/common/extensions/manifest_handler.h"
17 #include "chrome/common/extensions/unpacker.h" 15 #include "chrome/common/extensions/unpacker.h"
18 #include "content/public/test/test_browser_thread.h" 16 #include "content/public/test/test_browser_thread.h"
19 #include "extensions/common/constants.h" 17 #include "extensions/common/constants.h"
20 #include "testing/gmock/include/gmock/gmock.h" 18 #include "testing/gmock/include/gmock/gmock.h"
21 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
22 #include "third_party/skia/include/core/SkBitmap.h" 20 #include "third_party/skia/include/core/SkBitmap.h"
23 21
24 using content::BrowserThread; 22 using content::BrowserThread;
25 using testing::_; 23 using testing::_;
26 using testing::Invoke; 24 using testing::Invoke;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 class SandboxedUnpackerTest : public testing::Test { 59 class SandboxedUnpackerTest : public testing::Test {
62 public: 60 public:
63 virtual void SetUp() { 61 virtual void SetUp() {
64 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 62 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
65 ASSERT_TRUE(extensions_dir_.CreateUniqueTempDir()); 63 ASSERT_TRUE(extensions_dir_.CreateUniqueTempDir());
66 file_thread_.reset(new content::TestBrowserThread(BrowserThread::FILE, 64 file_thread_.reset(new content::TestBrowserThread(BrowserThread::FILE,
67 &loop_)); 65 &loop_));
68 // It will delete itself. 66 // It will delete itself.
69 client_ = new MockSandboxedUnpackerClient; 67 client_ = new MockSandboxedUnpackerClient;
70 client_->DelegateToFake(); 68 client_->DelegateToFake();
71 (new extensions::DefaultLocaleHandler)->Register();
72 } 69 }
73 70
74 virtual void TearDown() { 71 virtual void TearDown() {
75 // Need to destruct SandboxedUnpacker before the message loop since 72 // Need to destruct SandboxedUnpacker before the message loop since
76 // it posts a task to it. 73 // it posts a task to it.
77 sandboxed_unpacker_ = NULL; 74 sandboxed_unpacker_ = NULL;
78 loop_.RunUntilIdle(); 75 loop_.RunUntilIdle();
79 ManifestHandler::ClearRegistryForTesting();
80 } 76 }
81 77
82 void SetupUnpacker(const std::string& crx_name) { 78 void SetupUnpacker(const std::string& crx_name) {
83 base::FilePath original_path; 79 base::FilePath original_path;
84 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &original_path)); 80 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &original_path));
85 original_path = original_path.AppendASCII("extensions") 81 original_path = original_path.AppendASCII("extensions")
86 .AppendASCII("unpacker") 82 .AppendASCII("unpacker")
87 .AppendASCII(crx_name); 83 .AppendASCII(crx_name);
88 ASSERT_TRUE(file_util::PathExists(original_path)) << original_path.value(); 84 ASSERT_TRUE(file_util::PathExists(original_path)) << original_path.value();
89 85
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 // Check that there is newer _locales/en_US/messages.json file. 212 // Check that there is newer _locales/en_US/messages.json file.
217 base::PlatformFileInfo new_info; 213 base::PlatformFileInfo new_info;
218 EXPECT_TRUE(file_util::GetFileInfo(messages_file, &new_info)); 214 EXPECT_TRUE(file_util::GetFileInfo(messages_file, &new_info));
219 215
220 EXPECT_TRUE(new_info.last_modified > old_info.last_modified); 216 EXPECT_TRUE(new_info.last_modified > old_info.last_modified);
221 217
222 ASSERT_TRUE(TempFilesRemoved()); 218 ASSERT_TRUE(TempFilesRemoved());
223 } 219 }
224 220
225 } // namespace extensions 221 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/image_loader_unittest.cc ('k') | chrome/browser/extensions/script_bubble_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698