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_path.h" | 7 #include "base/file_path.h" |
| 8 #include "base/files/scoped_temp_dir.h" |
8 #include "base/path_service.h" | 9 #include "base/path_service.h" |
9 #include "base/scoped_temp_dir.h" | |
10 #include "chrome/installer/mini_installer/decompress.h" | 10 #include "chrome/installer/mini_installer/decompress.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
12 | 12 |
13 TEST(MiniDecompressTest, ExpandTest) { | 13 TEST(MiniDecompressTest, ExpandTest) { |
14 FilePath source_path; | 14 FilePath source_path; |
15 PathService::Get(base::DIR_SOURCE_ROOT, &source_path); | 15 PathService::Get(base::DIR_SOURCE_ROOT, &source_path); |
16 source_path = source_path.Append(FILE_PATH_LITERAL("chrome")) | 16 source_path = source_path.Append(FILE_PATH_LITERAL("chrome")) |
17 .Append(FILE_PATH_LITERAL("installer")) | 17 .Append(FILE_PATH_LITERAL("installer")) |
18 .Append(FILE_PATH_LITERAL("test")) | 18 .Append(FILE_PATH_LITERAL("test")) |
19 .Append(FILE_PATH_LITERAL("data")) | 19 .Append(FILE_PATH_LITERAL("data")) |
20 .Append(FILE_PATH_LITERAL("SETUP.EX_")); | 20 .Append(FILE_PATH_LITERAL("SETUP.EX_")); |
21 | 21 |
22 // Prepare a temp folder that will be automatically deleted along with | 22 // Prepare a temp folder that will be automatically deleted along with |
23 // our temporary test data. | 23 // our temporary test data. |
24 ScopedTempDir temp_dir; | 24 base::ScopedTempDir temp_dir; |
25 EXPECT_TRUE(temp_dir.CreateUniqueTempDir()); | 25 EXPECT_TRUE(temp_dir.CreateUniqueTempDir()); |
26 FilePath dest_path(temp_dir.path().Append(FILE_PATH_LITERAL("setup.exe"))); | 26 FilePath dest_path(temp_dir.path().Append(FILE_PATH_LITERAL("setup.exe"))); |
27 | 27 |
28 // Decompress our test file. | 28 // Decompress our test file. |
29 EXPECT_TRUE(mini_installer::Expand(source_path.value().c_str(), | 29 EXPECT_TRUE(mini_installer::Expand(source_path.value().c_str(), |
30 dest_path.value().c_str())); | 30 dest_path.value().c_str())); |
31 | 31 |
32 // Check if the expanded file is a valid executable. | 32 // Check if the expanded file is a valid executable. |
33 DWORD type = static_cast<DWORD>(-1); | 33 DWORD type = static_cast<DWORD>(-1); |
34 EXPECT_TRUE(GetBinaryType(dest_path.value().c_str(), &type)); | 34 EXPECT_TRUE(GetBinaryType(dest_path.value().c_str(), &type)); |
35 EXPECT_EQ(SCS_32BIT_BINARY, type); | 35 EXPECT_EQ(SCS_32BIT_BINARY, type); |
36 } | 36 } |
OLD | NEW |