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/files/file_path.h" | 7 #include "base/files/file_path.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/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 base::FilePath source_path; | 14 base::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 base::ScopedTempDir temp_dir; | 24 base::ScopedTempDir temp_dir; |
25 EXPECT_TRUE(temp_dir.CreateUniqueTempDir()); | 25 EXPECT_TRUE(temp_dir.CreateUniqueTempDir()); |
26 base::FilePath dest_path( | 26 base::FilePath dest_path( |
27 temp_dir.path().Append(FILE_PATH_LITERAL("setup.exe"))); | 27 temp_dir.GetPath().Append(FILE_PATH_LITERAL("setup.exe"))); |
28 | 28 |
29 // Decompress our test file. | 29 // Decompress our test file. |
30 EXPECT_TRUE(mini_installer::Expand(source_path.value().c_str(), | 30 EXPECT_TRUE(mini_installer::Expand(source_path.value().c_str(), |
31 dest_path.value().c_str())); | 31 dest_path.value().c_str())); |
32 | 32 |
33 // Check if the expanded file is a valid executable. | 33 // Check if the expanded file is a valid executable. |
34 DWORD type = static_cast<DWORD>(-1); | 34 DWORD type = static_cast<DWORD>(-1); |
35 EXPECT_TRUE(GetBinaryType(dest_path.value().c_str(), &type)); | 35 EXPECT_TRUE(GetBinaryType(dest_path.value().c_str(), &type)); |
36 EXPECT_EQ(static_cast<DWORD>(SCS_32BIT_BINARY), type); | 36 EXPECT_EQ(static_cast<DWORD>(SCS_32BIT_BINARY), type); |
37 } | 37 } |
OLD | NEW |