| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/base_paths.h" | 5 #include "base/base_paths.h" |
| 6 #include "base/bind.h" | 6 #include "base/bind.h" |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
| 10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
| 11 #include "base/message_loop/message_loop.h" | |
| 12 #include "base/path_service.h" | 11 #include "base/path_service.h" |
| 13 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
| 14 #include "base/values.h" | 13 #include "base/values.h" |
| 15 #include "components/component_updater/component_patcher.h" | 14 #include "components/component_updater/component_patcher.h" |
| 16 #include "components/component_updater/component_patcher_operation.h" | 15 #include "components/component_updater/component_patcher_operation.h" |
| 17 #include "components/component_updater/component_updater_service.h" | 16 #include "components/component_updater/component_updater_service.h" |
| 18 #include "components/component_updater/test/component_patcher_unittest.h" | 17 #include "components/component_updater/test/component_patcher_unittest.h" |
| 19 #include "components/component_updater/test/test_installer.h" | 18 #include "components/component_updater/test/test_installer.h" |
| 20 #include "content/public/browser/browser_thread.h" | |
| 21 #include "courgette/courgette.h" | 19 #include "courgette/courgette.h" |
| 22 #include "courgette/third_party/bsdiff.h" | 20 #include "courgette/third_party/bsdiff.h" |
| 23 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
| 24 | 22 |
| 25 namespace { | 23 namespace { |
| 26 | 24 |
| 27 class TestCallback { | 25 class TestCallback { |
| 28 public: | 26 public: |
| 29 TestCallback(); | 27 TestCallback(); |
| 30 virtual ~TestCallback() {} | 28 virtual ~TestCallback() {} |
| (...skipping 30 matching lines...) Expand all Loading... |
| 61 .AppendASCII("component_updater").AppendASCII(file); | 59 .AppendASCII("component_updater").AppendASCII(file); |
| 62 } | 60 } |
| 63 | 61 |
| 64 } // namespace | 62 } // namespace |
| 65 | 63 |
| 66 ComponentPatcherOperationTest::ComponentPatcherOperationTest() { | 64 ComponentPatcherOperationTest::ComponentPatcherOperationTest() { |
| 67 EXPECT_TRUE(unpack_dir_.CreateUniqueTempDir()); | 65 EXPECT_TRUE(unpack_dir_.CreateUniqueTempDir()); |
| 68 EXPECT_TRUE(input_dir_.CreateUniqueTempDir()); | 66 EXPECT_TRUE(input_dir_.CreateUniqueTempDir()); |
| 69 EXPECT_TRUE(installed_dir_.CreateUniqueTempDir()); | 67 EXPECT_TRUE(installed_dir_.CreateUniqueTempDir()); |
| 70 installer_.reset(new ReadOnlyTestInstaller(installed_dir_.path())); | 68 installer_.reset(new ReadOnlyTestInstaller(installed_dir_.path())); |
| 71 task_runner_ = content::BrowserThread::GetMessageLoopProxyForThread( | 69 task_runner_ = base::MessageLoop::current()->task_runner(); |
| 72 content::BrowserThread::FILE); | |
| 73 } | 70 } |
| 74 | 71 |
| 75 ComponentPatcherOperationTest::~ComponentPatcherOperationTest() { | 72 ComponentPatcherOperationTest::~ComponentPatcherOperationTest() { |
| 76 } | 73 } |
| 77 | 74 |
| 78 // Verify that a 'create' delta update operation works correctly. | 75 // Verify that a 'create' delta update operation works correctly. |
| 79 TEST_F(ComponentPatcherOperationTest, CheckCreateOperation) { | 76 TEST_F(ComponentPatcherOperationTest, CheckCreateOperation) { |
| 80 EXPECT_TRUE(base::CopyFile( | 77 EXPECT_TRUE(base::CopyFile( |
| 81 test_file("binary_output.bin"), | 78 test_file("binary_output.bin"), |
| 82 input_dir_.path().Append(FILE_PATH_LITERAL("binary_output.bin")))); | 79 input_dir_.path().Append(FILE_PATH_LITERAL("binary_output.bin")))); |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 | 196 |
| 200 EXPECT_EQ(true, callback.called_); | 197 EXPECT_EQ(true, callback.called_); |
| 201 EXPECT_EQ(ComponentUnpacker::kNone, callback.error_); | 198 EXPECT_EQ(ComponentUnpacker::kNone, callback.error_); |
| 202 EXPECT_EQ(0, callback.extra_code_); | 199 EXPECT_EQ(0, callback.extra_code_); |
| 203 EXPECT_TRUE(base::ContentsEqual( | 200 EXPECT_TRUE(base::ContentsEqual( |
| 204 unpack_dir_.path().Append(FILE_PATH_LITERAL("output.bin")), | 201 unpack_dir_.path().Append(FILE_PATH_LITERAL("output.bin")), |
| 205 test_file("binary_output.bin"))); | 202 test_file("binary_output.bin"))); |
| 206 } | 203 } |
| 207 | 204 |
| 208 } // namespace component_updater | 205 } // namespace component_updater |
| OLD | NEW |