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