This source file includes following definitions.
- SetUpTestCase
- TearDownTestCase
- SetUp
- TearDown
- TEST_F
#include "base/file_util.h"
#include "base/files/file_path.h"
#include "base/files/scoped_temp_dir.h"
#include "base/path_service.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/installer/setup/archive_patch_helper.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace {
class ArchivePatchHelperTest : public testing::Test {
protected:
static void SetUpTestCase() {
ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &data_dir_));
data_dir_ = data_dir_.AppendASCII("installer");
ASSERT_TRUE(base::PathExists(data_dir_));
}
static void TearDownTestCase() {
data_dir_.clear();
}
virtual void SetUp() OVERRIDE {
ASSERT_TRUE(test_dir_.CreateUniqueTempDir());
}
virtual void TearDown() OVERRIDE {
ASSERT_TRUE(test_dir_.Delete());
}
static base::FilePath data_dir_;
base::ScopedTempDir test_dir_;
};
base::FilePath ArchivePatchHelperTest::data_dir_;
}
TEST_F(ArchivePatchHelperTest, Patching) {
base::FilePath src = data_dir_.AppendASCII("archive1.7z");
base::FilePath patch = data_dir_.AppendASCII("archive.diff");
base::FilePath dest = test_dir_.path().AppendASCII("archive2.7z");
installer::ArchivePatchHelper archive_helper(test_dir_.path(),
base::FilePath(),
src,
dest);
archive_helper.set_last_uncompressed_file(patch);
EXPECT_TRUE(archive_helper.EnsemblePatch() || archive_helper.BinaryPatch());
base::FilePath base = data_dir_.AppendASCII("archive2.7z");
EXPECT_TRUE(base::ContentsEqual(dest, base));
}