OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/files/file_path.h" | 6 #include "base/files/file_path.h" |
7 #include "base/files/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/macros.h" | 9 #include "base/macros.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 const char app_name[] = "CalculatorFake.app"; | 50 const char app_name[] = "CalculatorFake.app"; |
51 base::FilePath src = data_dir_.Append(app_name); | 51 base::FilePath src = data_dir_.Append(app_name); |
52 base::FilePath dest = FileSelectHelper::ZipPackage(src); | 52 base::FilePath dest = FileSelectHelper::ZipPackage(src); |
53 ASSERT_FALSE(dest.empty()); | 53 ASSERT_FALSE(dest.empty()); |
54 ASSERT_TRUE(base::PathExists(dest)); | 54 ASSERT_TRUE(base::PathExists(dest)); |
55 | 55 |
56 base::ScopedTempDir temp_dir; | 56 base::ScopedTempDir temp_dir; |
57 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 57 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
58 | 58 |
59 // Unzip the package into a temporary directory. | 59 // Unzip the package into a temporary directory. |
60 CommandLine cl(base::FilePath("/usr/bin/unzip")); | 60 base::CommandLine cl(base::FilePath("/usr/bin/unzip")); |
61 cl.AppendArg(dest.value().c_str()); | 61 cl.AppendArg(dest.value().c_str()); |
62 cl.AppendArg("-d"); | 62 cl.AppendArg("-d"); |
63 cl.AppendArg(temp_dir.path().value().c_str()); | 63 cl.AppendArg(temp_dir.path().value().c_str()); |
64 std::string output; | 64 std::string output; |
65 EXPECT_TRUE(base::GetAppOutput(cl, &output)); | 65 EXPECT_TRUE(base::GetAppOutput(cl, &output)); |
66 | 66 |
67 // Verify that several key files haven't changed. | 67 // Verify that several key files haven't changed. |
68 const char* files_to_verify[] = {"Contents/Info.plist", | 68 const char* files_to_verify[] = {"Contents/Info.plist", |
69 "Contents/MacOS/Calculator", | 69 "Contents/MacOS/Calculator", |
70 "Contents/_CodeSignature/CodeResources"}; | 70 "Contents/_CodeSignature/CodeResources"}; |
71 size_t file_count = arraysize(files_to_verify); | 71 size_t file_count = arraysize(files_to_verify); |
72 for (size_t i = 0; i < file_count; i++) { | 72 for (size_t i = 0; i < file_count; i++) { |
73 const char* relative_path = files_to_verify[i]; | 73 const char* relative_path = files_to_verify[i]; |
74 base::FilePath orig_file = src.Append(relative_path); | 74 base::FilePath orig_file = src.Append(relative_path); |
75 base::FilePath final_file = | 75 base::FilePath final_file = |
76 temp_dir.path().Append(app_name).Append(relative_path); | 76 temp_dir.path().Append(app_name).Append(relative_path); |
77 EXPECT_TRUE(base::ContentsEqual(orig_file, final_file)); | 77 EXPECT_TRUE(base::ContentsEqual(orig_file, final_file)); |
78 } | 78 } |
79 } | 79 } |
80 #endif // defined(OS_MACOSX) && !defined(OS_IOS) | 80 #endif // defined(OS_MACOSX) && !defined(OS_IOS) |
OLD | NEW |