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

Unified Diff: chrome/browser/extensions/sandboxed_unpacker_unittest.cc

Issue 864093002: Move sandboxed_unpacker.{h,cc} from chrome/ to extensions/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix compile errors Created 5 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/extensions/sandboxed_unpacker.cc ('k') | chrome/browser/extensions/startup_helper.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/sandboxed_unpacker_unittest.cc
diff --git a/chrome/browser/extensions/sandboxed_unpacker_unittest.cc b/chrome/browser/extensions/sandboxed_unpacker_unittest.cc
deleted file mode 100644
index 4d46e7c47ca5046c2978b3aacd04d0350997a62b..0000000000000000000000000000000000000000
--- a/chrome/browser/extensions/sandboxed_unpacker_unittest.cc
+++ /dev/null
@@ -1,126 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "base/bind.h"
-#include "base/files/file_util.h"
-#include "base/memory/ref_counted.h"
-#include "base/message_loop/message_loop.h"
-#include "base/path_service.h"
-#include "base/run_loop.h"
-#include "base/strings/string_util.h"
-#include "base/values.h"
-#include "chrome/browser/extensions/sandboxed_unpacker.h"
-#include "chrome/common/chrome_paths.h"
-#include "content/public/test/test_browser_thread_bundle.h"
-#include "content/public/test/test_utils.h"
-#include "extensions/common/constants.h"
-#include "extensions/common/extension.h"
-#include "extensions/common/extension_paths.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "third_party/skia/include/core/SkBitmap.h"
-
-namespace extensions {
-
-class MockSandboxedUnpackerClient : public SandboxedUnpackerClient {
- public:
-
- void WaitForUnpack() {
- scoped_refptr<content::MessageLoopRunner> runner =
- new content::MessageLoopRunner;
- quit_closure_ = runner->QuitClosure();
- runner->Run();
- }
-
- base::FilePath temp_dir() const { return temp_dir_; }
-
- private:
- ~MockSandboxedUnpackerClient() override {}
-
- void OnUnpackSuccess(const base::FilePath& temp_dir,
- const base::FilePath& extension_root,
- const base::DictionaryValue* original_manifest,
- const Extension* extension,
- const SkBitmap& install_icon) override {
- temp_dir_ = temp_dir;
- quit_closure_.Run();
-
- }
-
- void OnUnpackFailure(const base::string16& error) override {
- ASSERT_TRUE(false);
- }
-
- base::Closure quit_closure_;
- base::FilePath temp_dir_;
-};
-
-class SandboxedUnpackerTest : public testing::Test {
- public:
- void SetUp() override {
- ASSERT_TRUE(extensions_dir_.CreateUniqueTempDir());
- browser_threads_.reset(new content::TestBrowserThreadBundle(
- content::TestBrowserThreadBundle::IO_MAINLOOP));
- in_process_utility_thread_helper_.reset(
- new content::InProcessUtilityThreadHelper);
- // It will delete itself.
- client_ = new MockSandboxedUnpackerClient;
- }
-
- void TearDown() override {
- // Need to destruct SandboxedUnpacker before the message loop since
- // it posts a task to it.
- sandboxed_unpacker_ = NULL;
- base::RunLoop().RunUntilIdle();
- }
-
- void SetupUnpacker(const std::string& crx_name) {
- base::FilePath original_path;
- ASSERT_TRUE(PathService::Get(extensions::DIR_TEST_DATA, &original_path));
- original_path = original_path.AppendASCII("unpacker").AppendASCII(crx_name);
- ASSERT_TRUE(base::PathExists(original_path)) << original_path.value();
-
- sandboxed_unpacker_ = new SandboxedUnpacker(
- original_path,
- Manifest::INTERNAL,
- Extension::NO_FLAGS,
- extensions_dir_.path(),
- base::MessageLoopProxy::current(),
- client_);
-
- base::MessageLoopProxy::current()->PostTask(
- FROM_HERE,
- base::Bind(&SandboxedUnpacker::Start, sandboxed_unpacker_.get()));
- client_->WaitForUnpack();
- }
-
- base::FilePath GetInstallPath() {
- return client_->temp_dir().AppendASCII(kTempExtensionName);
- }
-
- protected:
- base::ScopedTempDir extensions_dir_;
- MockSandboxedUnpackerClient* client_;
- scoped_refptr<SandboxedUnpacker> sandboxed_unpacker_;
- scoped_ptr<content::TestBrowserThreadBundle> browser_threads_;
- scoped_ptr<content::InProcessUtilityThreadHelper>
- in_process_utility_thread_helper_;
-};
-
-TEST_F(SandboxedUnpackerTest, NoCatalogsSuccess) {
- SetupUnpacker("no_l10n.crx");
- // Check that there is no _locales folder.
- base::FilePath install_path =
- GetInstallPath().Append(kLocaleFolder);
- EXPECT_FALSE(base::PathExists(install_path));
-}
-
-TEST_F(SandboxedUnpackerTest, WithCatalogsSuccess) {
- SetupUnpacker("good_l10n.crx");
- // Check that there is _locales folder.
- base::FilePath install_path =
- GetInstallPath().Append(kLocaleFolder);
- EXPECT_TRUE(base::PathExists(install_path));
-}
-
-} // namespace extensions
« no previous file with comments | « chrome/browser/extensions/sandboxed_unpacker.cc ('k') | chrome/browser/extensions/startup_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698