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

Unified Diff: components/component_updater/test/component_patcher_unittest.cc

Issue 808773005: Move most of the component updater artifacts to update_client. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
Index: components/component_updater/test/component_patcher_unittest.cc
diff --git a/components/component_updater/test/component_patcher_unittest.cc b/components/component_updater/test/component_patcher_unittest.cc
deleted file mode 100644
index 2b980bd1b4647c1b200416f373a6510cb3d9fed7..0000000000000000000000000000000000000000
--- a/components/component_updater/test/component_patcher_unittest.cc
+++ /dev/null
@@ -1,207 +0,0 @@
-// Copyright 2013 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/base_paths.h"
-#include "base/bind.h"
-#include "base/bind_helpers.h"
-#include "base/compiler_specific.h"
-#include "base/files/file_path.h"
-#include "base/files/file_util.h"
-#include "base/files/scoped_temp_dir.h"
-#include "base/macros.h"
-#include "base/path_service.h"
-#include "base/run_loop.h"
-#include "base/values.h"
-#include "components/component_updater/component_patcher.h"
-#include "components/component_updater/component_patcher_operation.h"
-#include "components/component_updater/component_updater_service.h"
-#include "components/component_updater/test/component_patcher_unittest.h"
-#include "components/component_updater/test/test_installer.h"
-#include "courgette/courgette.h"
-#include "courgette/third_party/bsdiff.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace {
-
-class TestCallback {
- public:
- TestCallback();
- virtual ~TestCallback() {}
- void Set(component_updater::ComponentUnpacker::Error error, int extra_code);
-
- int error_;
- int extra_code_;
- bool called_;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(TestCallback);
-};
-
-TestCallback::TestCallback() : error_(-1), extra_code_(-1), called_(false) {
-}
-
-void TestCallback::Set(component_updater::ComponentUnpacker::Error error,
- int extra_code) {
- error_ = error;
- extra_code_ = extra_code;
- called_ = true;
-}
-
-} // namespace
-
-namespace component_updater {
-
-namespace {
-
-base::FilePath test_file(const char* file) {
- base::FilePath path;
- PathService::Get(base::DIR_SOURCE_ROOT, &path);
- return path.AppendASCII("components").AppendASCII("test").AppendASCII("data")
- .AppendASCII("component_updater").AppendASCII(file);
-}
-
-} // namespace
-
-ComponentPatcherOperationTest::ComponentPatcherOperationTest() {
- EXPECT_TRUE(unpack_dir_.CreateUniqueTempDir());
- EXPECT_TRUE(input_dir_.CreateUniqueTempDir());
- EXPECT_TRUE(installed_dir_.CreateUniqueTempDir());
- installer_.reset(new ReadOnlyTestInstaller(installed_dir_.path()));
- task_runner_ = base::MessageLoop::current()->task_runner();
-}
-
-ComponentPatcherOperationTest::~ComponentPatcherOperationTest() {
-}
-
-// Verify that a 'create' delta update operation works correctly.
-TEST_F(ComponentPatcherOperationTest, CheckCreateOperation) {
- EXPECT_TRUE(base::CopyFile(
- test_file("binary_output.bin"),
- input_dir_.path().Append(FILE_PATH_LITERAL("binary_output.bin"))));
-
- scoped_ptr<base::DictionaryValue> command_args(new base::DictionaryValue());
- command_args->SetString("output", "output.bin");
- command_args->SetString("sha256", binary_output_hash);
- command_args->SetString("op", "create");
- command_args->SetString("patch", "binary_output.bin");
-
- TestCallback callback;
- scoped_refptr<DeltaUpdateOp> op = new DeltaUpdateOpCreate();
- op->Run(command_args.get(),
- input_dir_.path(),
- unpack_dir_.path(),
- NULL,
- base::Bind(&TestCallback::Set, base::Unretained(&callback)),
- task_runner_);
- base::RunLoop().RunUntilIdle();
-
- EXPECT_EQ(true, callback.called_);
- EXPECT_EQ(ComponentUnpacker::kNone, callback.error_);
- EXPECT_EQ(0, callback.extra_code_);
- EXPECT_TRUE(base::ContentsEqual(
- unpack_dir_.path().Append(FILE_PATH_LITERAL("output.bin")),
- test_file("binary_output.bin")));
-}
-
-// Verify that a 'copy' delta update operation works correctly.
-TEST_F(ComponentPatcherOperationTest, CheckCopyOperation) {
- EXPECT_TRUE(base::CopyFile(
- test_file("binary_output.bin"),
- installed_dir_.path().Append(FILE_PATH_LITERAL("binary_output.bin"))));
-
- scoped_ptr<base::DictionaryValue> command_args(new base::DictionaryValue());
- command_args->SetString("output", "output.bin");
- command_args->SetString("sha256", binary_output_hash);
- command_args->SetString("op", "copy");
- command_args->SetString("input", "binary_output.bin");
-
- TestCallback callback;
- scoped_refptr<DeltaUpdateOp> op = new DeltaUpdateOpCopy();
- op->Run(command_args.get(),
- input_dir_.path(),
- unpack_dir_.path(),
- installer_.get(),
- base::Bind(&TestCallback::Set, base::Unretained(&callback)),
- task_runner_);
- base::RunLoop().RunUntilIdle();
-
- EXPECT_EQ(true, callback.called_);
- EXPECT_EQ(ComponentUnpacker::kNone, callback.error_);
- EXPECT_EQ(0, callback.extra_code_);
- EXPECT_TRUE(base::ContentsEqual(
- unpack_dir_.path().Append(FILE_PATH_LITERAL("output.bin")),
- test_file("binary_output.bin")));
-}
-
-// Verify that a 'courgette' delta update operation works correctly.
-TEST_F(ComponentPatcherOperationTest, CheckCourgetteOperation) {
- EXPECT_TRUE(base::CopyFile(
- test_file("binary_input.bin"),
- installed_dir_.path().Append(FILE_PATH_LITERAL("binary_input.bin"))));
- EXPECT_TRUE(base::CopyFile(test_file("binary_courgette_patch.bin"),
- input_dir_.path().Append(FILE_PATH_LITERAL(
- "binary_courgette_patch.bin"))));
-
- scoped_ptr<base::DictionaryValue> command_args(new base::DictionaryValue());
- command_args->SetString("output", "output.bin");
- command_args->SetString("sha256", binary_output_hash);
- command_args->SetString("op", "courgette");
- command_args->SetString("input", "binary_input.bin");
- command_args->SetString("patch", "binary_courgette_patch.bin");
-
- TestCallback callback;
- scoped_refptr<DeltaUpdateOp> op =
- CreateDeltaUpdateOp("courgette", NULL /* out_of_process_patcher */);
- op->Run(command_args.get(),
- input_dir_.path(),
- unpack_dir_.path(),
- installer_.get(),
- base::Bind(&TestCallback::Set, base::Unretained(&callback)),
- task_runner_);
- base::RunLoop().RunUntilIdle();
-
- EXPECT_EQ(true, callback.called_);
- EXPECT_EQ(ComponentUnpacker::kNone, callback.error_);
- EXPECT_EQ(0, callback.extra_code_);
- EXPECT_TRUE(base::ContentsEqual(
- unpack_dir_.path().Append(FILE_PATH_LITERAL("output.bin")),
- test_file("binary_output.bin")));
-}
-
-// Verify that a 'bsdiff' delta update operation works correctly.
-TEST_F(ComponentPatcherOperationTest, CheckBsdiffOperation) {
- EXPECT_TRUE(base::CopyFile(
- test_file("binary_input.bin"),
- installed_dir_.path().Append(FILE_PATH_LITERAL("binary_input.bin"))));
- EXPECT_TRUE(base::CopyFile(
- test_file("binary_bsdiff_patch.bin"),
- input_dir_.path().Append(FILE_PATH_LITERAL("binary_bsdiff_patch.bin"))));
-
- scoped_ptr<base::DictionaryValue> command_args(new base::DictionaryValue());
- command_args->SetString("output", "output.bin");
- command_args->SetString("sha256", binary_output_hash);
- command_args->SetString("op", "courgette");
- command_args->SetString("input", "binary_input.bin");
- command_args->SetString("patch", "binary_bsdiff_patch.bin");
-
- TestCallback callback;
- scoped_refptr<DeltaUpdateOp> op =
- CreateDeltaUpdateOp("bsdiff", NULL /* out_of_process_patcher */);
- op->Run(command_args.get(),
- input_dir_.path(),
- unpack_dir_.path(),
- installer_.get(),
- base::Bind(&TestCallback::Set, base::Unretained(&callback)),
- task_runner_);
- base::RunLoop().RunUntilIdle();
-
- EXPECT_EQ(true, callback.called_);
- EXPECT_EQ(ComponentUnpacker::kNone, callback.error_);
- EXPECT_EQ(0, callback.extra_code_);
- EXPECT_TRUE(base::ContentsEqual(
- unpack_dir_.path().Append(FILE_PATH_LITERAL("output.bin")),
- test_file("binary_output.bin")));
-}
-
-} // namespace component_updater

Powered by Google App Engine
This is Rietveld 408576698