OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <windows.h> | 5 #include <windows.h> |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/files/file_util.h" |
8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 #include "chrome/common/chrome_paths.h" | 10 #include "chrome/common/chrome_paths.h" |
11 #include "chrome/installer/util/lzma_util.h" | 11 #include "chrome/installer/util/lzma_util.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
13 | 13 |
14 namespace { | 14 namespace { |
| 15 |
15 class LzmaUtilTest : public testing::Test { | 16 class LzmaUtilTest : public testing::Test { |
16 protected: | 17 protected: |
17 virtual void SetUp() { | 18 virtual void SetUp() { |
18 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &data_dir_)); | 19 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &data_dir_)); |
19 data_dir_ = data_dir_.AppendASCII("installer"); | 20 data_dir_ = data_dir_.AppendASCII("installer"); |
20 ASSERT_TRUE(base::PathExists(data_dir_)); | 21 ASSERT_TRUE(base::PathExists(data_dir_)); |
21 | 22 |
22 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 23 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
23 } | 24 } |
24 | 25 |
25 base::ScopedTempDir temp_dir_; | 26 base::ScopedTempDir temp_dir_; |
26 | 27 |
27 // The path to input data used in tests. | 28 // The path to input data used in tests. |
28 base::FilePath data_dir_; | 29 base::FilePath data_dir_; |
29 }; | 30 }; |
30 }; | 31 |
| 32 } // namespace |
31 | 33 |
32 // Test that we can open archives successfully. | 34 // Test that we can open archives successfully. |
33 TEST_F(LzmaUtilTest, OpenArchiveTest) { | 35 TEST_F(LzmaUtilTest, OpenArchiveTest) { |
34 base::FilePath archive = data_dir_.AppendASCII("archive1.7z"); | 36 base::FilePath archive = data_dir_.AppendASCII("archive1.7z"); |
35 LzmaUtil lzma_util; | 37 LzmaUtil lzma_util; |
36 EXPECT_EQ(lzma_util.OpenArchive(archive.value()), NO_ERROR); | 38 EXPECT_EQ(lzma_util.OpenArchive(archive.value()), NO_ERROR); |
37 | 39 |
38 // We allow opening another archive (which will automatically close the first | 40 // We allow opening another archive (which will automatically close the first |
39 // archive). | 41 // archive). |
40 archive = data_dir_.AppendASCII("archive2.7z"); | 42 archive = data_dir_.AppendASCII("archive2.7z"); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 archive = data_dir_.AppendASCII("archive2.7z"); | 111 archive = data_dir_.AppendASCII("archive2.7z"); |
110 EXPECT_EQ(LzmaUtil::UnPackArchive(archive.value(), extract_dir.value(), | 112 EXPECT_EQ(LzmaUtil::UnPackArchive(archive.value(), extract_dir.value(), |
111 &unpacked_file), NO_ERROR); | 113 &unpacked_file), NO_ERROR); |
112 EXPECT_TRUE(base::PathExists(extract_dir.AppendASCII("b.exe"))); | 114 EXPECT_TRUE(base::PathExists(extract_dir.AppendASCII("b.exe"))); |
113 EXPECT_TRUE(unpacked_file == extract_dir.AppendASCII("b.exe").value()); | 115 EXPECT_TRUE(unpacked_file == extract_dir.AppendASCII("b.exe").value()); |
114 | 116 |
115 archive = data_dir_.AppendASCII("invalid_archive.7z"); | 117 archive = data_dir_.AppendASCII("invalid_archive.7z"); |
116 EXPECT_NE(LzmaUtil::UnPackArchive(archive.value(), extract_dir.value(), | 118 EXPECT_NE(LzmaUtil::UnPackArchive(archive.value(), extract_dir.value(), |
117 &unpacked_file), NO_ERROR); | 119 &unpacked_file), NO_ERROR); |
118 } | 120 } |
OLD | NEW |