Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(233)

Side by Side Diff: chrome/installer/util/lzma_util_unittest.cc

Issue 2321573002: //chrome misc: Change ScopedTempDir::path() to GetPath() (Closed)
Patch Set: Fix Win compilation Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_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"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 lzma_util.OpenArchive(archive.value())); 51 lzma_util.OpenArchive(archive.value()));
52 52
53 // Make sure non-existent archive returns error. 53 // Make sure non-existent archive returns error.
54 archive = data_dir_.AppendASCII("archive.non_existent.7z"); 54 archive = data_dir_.AppendASCII("archive.non_existent.7z");
55 EXPECT_EQ(static_cast<DWORD>(ERROR_FILE_NOT_FOUND), 55 EXPECT_EQ(static_cast<DWORD>(ERROR_FILE_NOT_FOUND),
56 lzma_util.OpenArchive(archive.value())); 56 lzma_util.OpenArchive(archive.value()));
57 } 57 }
58 58
59 // Test that we can extract archives successfully. 59 // Test that we can extract archives successfully.
60 TEST_F(LzmaUtilTest, UnPackTest) { 60 TEST_F(LzmaUtilTest, UnPackTest) {
61 base::FilePath extract_dir(temp_dir_.path()); 61 base::FilePath extract_dir(temp_dir_.GetPath());
62 extract_dir = extract_dir.AppendASCII("UnPackTest"); 62 extract_dir = extract_dir.AppendASCII("UnPackTest");
63 ASSERT_FALSE(base::PathExists(extract_dir)); 63 ASSERT_FALSE(base::PathExists(extract_dir));
64 EXPECT_TRUE(base::CreateDirectory(extract_dir)); 64 EXPECT_TRUE(base::CreateDirectory(extract_dir));
65 ASSERT_TRUE(base::PathExists(extract_dir)); 65 ASSERT_TRUE(base::PathExists(extract_dir));
66 66
67 base::FilePath archive = data_dir_.AppendASCII("archive1.7z"); 67 base::FilePath archive = data_dir_.AppendASCII("archive1.7z");
68 LzmaUtil lzma_util; 68 LzmaUtil lzma_util;
69 EXPECT_EQ(static_cast<DWORD>(NO_ERROR), 69 EXPECT_EQ(static_cast<DWORD>(NO_ERROR),
70 lzma_util.OpenArchive(archive.value())); 70 lzma_util.OpenArchive(archive.value()));
71 std::wstring unpacked_file; 71 std::wstring unpacked_file;
(...skipping 24 matching lines...) Expand all
96 lzma_util.OpenArchive(archive.value())); 96 lzma_util.OpenArchive(archive.value()));
97 EXPECT_EQ(static_cast<DWORD>(NO_ERROR), 97 EXPECT_EQ(static_cast<DWORD>(NO_ERROR),
98 lzma_util.UnPack(extract_dir.value(), &unpacked_file)); 98 lzma_util.UnPack(extract_dir.value(), &unpacked_file));
99 EXPECT_TRUE(base::PathExists(extract_dir.AppendASCII("archive\\a.exe"))); 99 EXPECT_TRUE(base::PathExists(extract_dir.AppendASCII("archive\\a.exe")));
100 EXPECT_TRUE(base::PathExists( 100 EXPECT_TRUE(base::PathExists(
101 extract_dir.AppendASCII("archive\\sub_dir\\text.txt"))); 101 extract_dir.AppendASCII("archive\\sub_dir\\text.txt")));
102 } 102 }
103 103
104 // Test the static method that can be used to unpack archives. 104 // Test the static method that can be used to unpack archives.
105 TEST_F(LzmaUtilTest, UnPackArchiveTest) { 105 TEST_F(LzmaUtilTest, UnPackArchiveTest) {
106 base::FilePath extract_dir(temp_dir_.path()); 106 base::FilePath extract_dir(temp_dir_.GetPath());
107 extract_dir = extract_dir.AppendASCII("UnPackArchiveTest"); 107 extract_dir = extract_dir.AppendASCII("UnPackArchiveTest");
108 ASSERT_FALSE(base::PathExists(extract_dir)); 108 ASSERT_FALSE(base::PathExists(extract_dir));
109 EXPECT_TRUE(base::CreateDirectory(extract_dir)); 109 EXPECT_TRUE(base::CreateDirectory(extract_dir));
110 ASSERT_TRUE(base::PathExists(extract_dir)); 110 ASSERT_TRUE(base::PathExists(extract_dir));
111 111
112 base::FilePath archive = data_dir_.AppendASCII("archive1.7z"); 112 base::FilePath archive = data_dir_.AppendASCII("archive1.7z");
113 std::wstring unpacked_file; 113 std::wstring unpacked_file;
114 EXPECT_EQ(NO_ERROR, 114 EXPECT_EQ(NO_ERROR,
115 LzmaUtil::UnPackArchive(archive.value(), extract_dir.value(), 115 LzmaUtil::UnPackArchive(archive.value(), extract_dir.value(),
116 &unpacked_file)); 116 &unpacked_file));
117 EXPECT_TRUE(base::PathExists(extract_dir.AppendASCII("a.exe"))); 117 EXPECT_TRUE(base::PathExists(extract_dir.AppendASCII("a.exe")));
118 EXPECT_TRUE(unpacked_file == extract_dir.AppendASCII("a.exe").value()); 118 EXPECT_TRUE(unpacked_file == extract_dir.AppendASCII("a.exe").value());
119 119
120 archive = data_dir_.AppendASCII("archive2.7z"); 120 archive = data_dir_.AppendASCII("archive2.7z");
121 EXPECT_EQ(NO_ERROR, 121 EXPECT_EQ(NO_ERROR,
122 LzmaUtil::UnPackArchive(archive.value(), extract_dir.value(), 122 LzmaUtil::UnPackArchive(archive.value(), extract_dir.value(),
123 &unpacked_file)); 123 &unpacked_file));
124 EXPECT_TRUE(base::PathExists(extract_dir.AppendASCII("b.exe"))); 124 EXPECT_TRUE(base::PathExists(extract_dir.AppendASCII("b.exe")));
125 EXPECT_TRUE(unpacked_file == extract_dir.AppendASCII("b.exe").value()); 125 EXPECT_TRUE(unpacked_file == extract_dir.AppendASCII("b.exe").value());
126 126
127 archive = data_dir_.AppendASCII("invalid_archive.7z"); 127 archive = data_dir_.AppendASCII("invalid_archive.7z");
128 EXPECT_NE(NO_ERROR, 128 EXPECT_NE(NO_ERROR,
129 LzmaUtil::UnPackArchive(archive.value(), extract_dir.value(), 129 LzmaUtil::UnPackArchive(archive.value(), extract_dir.value(),
130 &unpacked_file)); 130 &unpacked_file));
131 } 131 }
OLDNEW
« no previous file with comments | « chrome/installer/util/lzma_file_allocator_unittest.cc ('k') | chrome/installer/util/move_tree_work_item_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698