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

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

Issue 1120793007: [extensions] Replace MessageLoopProxy usage with ThreadTaskRunnerHandle (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
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/bind.h" 5 #include "base/bind.h"
6 #include "base/command_line.h" 6 #include "base/command_line.h"
7 #include "base/files/file_util.h" 7 #include "base/files/file_util.h"
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
Ken Rockot(use gerrit already) 2015/05/04 18:19:58 is this header still needed?
Pranay 2015/05/05 03:07:58 Not needed, got confused with MessageLoopRunner :)
10 #include "base/path_service.h" 10 #include "base/path_service.h"
11 #include "base/run_loop.h" 11 #include "base/run_loop.h"
12 #include "base/strings/string_util.h" 12 #include "base/strings/string_util.h"
13 #include "base/thread_task_runner_handle.h"
13 #include "base/values.h" 14 #include "base/values.h"
14 #include "content/public/test/test_browser_thread_bundle.h" 15 #include "content/public/test/test_browser_thread_bundle.h"
15 #include "content/public/test/test_utils.h" 16 #include "content/public/test/test_utils.h"
16 #include "extensions/browser/extensions_test.h" 17 #include "extensions/browser/extensions_test.h"
17 #include "extensions/browser/sandboxed_unpacker.h" 18 #include "extensions/browser/sandboxed_unpacker.h"
18 #include "extensions/common/constants.h" 19 #include "extensions/common/constants.h"
19 #include "extensions/common/extension.h" 20 #include "extensions/common/extension.h"
20 #include "extensions/common/extension_paths.h" 21 #include "extensions/common/extension_paths.h"
21 #include "extensions/common/switches.h" 22 #include "extensions/common/switches.h"
22 #include "testing/gtest/include/gtest/gtest.h" 23 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 void SetupUnpacker(const std::string& crx_name, 83 void SetupUnpacker(const std::string& crx_name,
83 const std::string& package_hash) { 84 const std::string& package_hash) {
84 base::FilePath original_path; 85 base::FilePath original_path;
85 ASSERT_TRUE(PathService::Get(extensions::DIR_TEST_DATA, &original_path)); 86 ASSERT_TRUE(PathService::Get(extensions::DIR_TEST_DATA, &original_path));
86 original_path = original_path.AppendASCII("unpacker").AppendASCII(crx_name); 87 original_path = original_path.AppendASCII("unpacker").AppendASCII(crx_name);
87 ASSERT_TRUE(base::PathExists(original_path)) << original_path.value(); 88 ASSERT_TRUE(base::PathExists(original_path)) << original_path.value();
88 89
89 sandboxed_unpacker_ = new SandboxedUnpacker( 90 sandboxed_unpacker_ = new SandboxedUnpacker(
90 extensions::CRXFileInfo(std::string(), original_path, package_hash), 91 extensions::CRXFileInfo(std::string(), original_path, package_hash),
91 Manifest::INTERNAL, Extension::NO_FLAGS, extensions_dir_.path(), 92 Manifest::INTERNAL, Extension::NO_FLAGS, extensions_dir_.path(),
92 base::MessageLoopProxy::current(), client_); 93 base::ThreadTaskRunnerHandle::Get(), client_);
93 94
94 base::MessageLoopProxy::current()->PostTask( 95 base::ThreadTaskRunnerHandle::Get()->PostTask(
95 FROM_HERE, 96 FROM_HERE,
96 base::Bind(&SandboxedUnpacker::Start, sandboxed_unpacker_.get())); 97 base::Bind(&SandboxedUnpacker::Start, sandboxed_unpacker_.get()));
97 client_->WaitForUnpack(); 98 client_->WaitForUnpack();
98 } 99 }
99 100
100 base::FilePath GetInstallPath() { 101 base::FilePath GetInstallPath() {
101 return client_->temp_dir().AppendASCII(kTempExtensionName); 102 return client_->temp_dir().AppendASCII(kTempExtensionName);
102 } 103 }
103 104
104 base::string16 GetInstallError() { return client_->unpack_err(); } 105 base::string16 GetInstallError() { return client_->unpack_err(); }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 EXPECT_EQ(base::string16(), GetInstallError()); 145 EXPECT_EQ(base::string16(), GetInstallError());
145 } 146 }
146 147
147 TEST_F(SandboxedUnpackerTest, SkipHashCheck) { 148 TEST_F(SandboxedUnpackerTest, SkipHashCheck) {
148 SetupUnpacker("good_l10n.crx", "badhash"); 149 SetupUnpacker("good_l10n.crx", "badhash");
149 // Check that there is no error message. 150 // Check that there is no error message.
150 EXPECT_EQ(base::string16(), GetInstallError()); 151 EXPECT_EQ(base::string16(), GetInstallError());
151 } 152 }
152 153
153 } // namespace extensions 154 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698