OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/test/mini_installer_test/mini_installer_test_util.h" | 5 #include "chrome/test/mini_installer_test/mini_installer_test_util.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
9 #include "base/platform_thread.h" | 9 #include "base/platform_thread.h" |
10 #include "base/process_util.h" | 10 #include "base/process_util.h" |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 return_command->append(mini_installer_constants::kChromeApplyTagParameters); | 83 return_command->append(mini_installer_constants::kChromeApplyTagParameters); |
84 VLOG(1) << "Command to run Apply tag: " << return_command->c_str(); | 84 VLOG(1) << "Command to run Apply tag: " << return_command->c_str(); |
85 return true; | 85 return true; |
86 } | 86 } |
87 | 87 |
88 std::wstring MiniInstallerTestUtil::GetFilePath(const wchar_t* exe_name) { | 88 std::wstring MiniInstallerTestUtil::GetFilePath(const wchar_t* exe_name) { |
89 FilePath installer_path; | 89 FilePath installer_path; |
90 PathService::Get(base::DIR_EXE, &installer_path); | 90 PathService::Get(base::DIR_EXE, &installer_path); |
91 installer_path = installer_path.Append(exe_name); | 91 installer_path = installer_path.Append(exe_name); |
92 VLOG(1) << "Chrome exe path: " << installer_path.value().c_str(); | 92 VLOG(1) << "Chrome exe path: " << installer_path.value().c_str(); |
93 return installer_path.ToWStringHack(); | 93 return installer_path.value(); |
94 } | 94 } |
95 | 95 |
96 // This method will first call GetLatestFile to get the list of all | 96 // This method will first call GetLatestFile to get the list of all |
97 // builds, sorted on creation time. Then goes through each build folder | 97 // builds, sorted on creation time. Then goes through each build folder |
98 // until it finds the installer file that matches the pattern argument. | 98 // until it finds the installer file that matches the pattern argument. |
99 bool MiniInstallerTestUtil::GetInstaller(const wchar_t* pattern, | 99 bool MiniInstallerTestUtil::GetInstaller(const wchar_t* pattern, |
100 std::wstring *path, const wchar_t* channel_type, bool chrome_frame) { | 100 std::wstring *path, const wchar_t* channel_type, bool chrome_frame) { |
101 FileInfoList builds_list; | 101 FileInfoList builds_list; |
102 FileInfoList exe_list; | 102 FileInfoList exe_list; |
103 std::wstring chrome_diff_installer( | 103 std::wstring chrome_diff_installer( |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 ret = FindNextFile(file_handle, &find_file_data); | 161 ret = FindNextFile(file_handle, &find_file_data); |
162 } | 162 } |
163 std::sort(file_details->rbegin(), file_details->rend(), &IsNewer); | 163 std::sort(file_details->rbegin(), file_details->rend(), &IsNewer); |
164 FindClose(file_handle); | 164 FindClose(file_handle); |
165 return return_val; | 165 return return_val; |
166 } | 166 } |
167 | 167 |
168 // This method retrieves the previous build version for the given diff | 168 // This method retrieves the previous build version for the given diff |
169 // installer path. | 169 // installer path. |
170 bool MiniInstallerTestUtil::GetPreviousBuildNumber(const std::wstring& path, | 170 bool MiniInstallerTestUtil::GetPreviousBuildNumber(const std::wstring& path, |
171 std::wstring *build_number) { | 171 std::wstring *build_number) { |
172 | 172 |
173 std::wstring diff_name = file_util::GetFilenameFromPath(path); | 173 std::wstring diff_name = FilePath(path).BaseName().value(); |
174 // We want to remove 'from_', so add its length to found index (which is 5) | 174 // We want to remove 'from_', so add its length to found index (which is 5) |
175 std::wstring::size_type start_position = diff_name.find(L"from_") + 5; | 175 std::wstring::size_type start_position = diff_name.find(L"from_") + 5; |
176 std::wstring::size_type end_position = diff_name.find(L"_c"); | 176 std::wstring::size_type end_position = diff_name.find(L"_c"); |
177 std::wstring::size_type size = end_position - start_position; | 177 std::wstring::size_type size = end_position - start_position; |
178 | 178 |
179 std::wstring build_no = diff_name.substr(start_position, size); | 179 std::wstring build_no = diff_name.substr(start_position, size); |
180 | 180 |
181 // Search for a build folder with this build suffix. | 181 // Search for a build folder with this build suffix. |
182 std::wstring pattern = L"*" + build_no; | 182 std::wstring pattern = L"*" + build_no; |
183 | 183 |
184 file_util::FileEnumerator files(FilePath( | 184 file_util::FileEnumerator files(FilePath( |
185 mini_installer_constants::kChromeDiffInstallerLocation), | 185 mini_installer_constants::kChromeDiffInstallerLocation), |
186 false, file_util::FileEnumerator::DIRECTORIES, pattern); | 186 false, file_util::FileEnumerator::DIRECTORIES, pattern); |
187 FilePath folder = files.Next(); | 187 FilePath folder = files.Next(); |
188 if (folder.empty()) | 188 if (folder.empty()) |
189 return false; | 189 return false; |
190 | 190 |
191 build_number->assign(folder.BaseName().ToWStringHack()); | 191 build_number->assign(folder.BaseName().value()); |
192 return true; | 192 return true; |
193 } | 193 } |
194 | 194 |
195 | 195 |
196 // This method will get the previous full installer path | 196 // This method will get the previous full installer path |
197 // from given diff installer path. It will first get the | 197 // from given diff installer path. It will first get the |
198 // filename from the diff installer path, gets the previous | 198 // filename from the diff installer path, gets the previous |
199 // build information from the filename, then computes the | 199 // build information from the filename, then computes the |
200 // path for previous full installer. | 200 // path for previous full installer. |
201 bool MiniInstallerTestUtil::GetPreviousFullInstaller( | 201 bool MiniInstallerTestUtil::GetPreviousFullInstaller( |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 } | 300 } |
301 return true; | 301 return true; |
302 } | 302 } |
303 | 303 |
304 bool MiniInstallerTestUtil::VerifyProcessHandleClosed( | 304 bool MiniInstallerTestUtil::VerifyProcessHandleClosed( |
305 base::ProcessHandle handle) { | 305 base::ProcessHandle handle) { |
306 DWORD result = WaitForSingleObject(handle, | 306 DWORD result = WaitForSingleObject(handle, |
307 TestTimeouts::large_test_timeout_ms()); | 307 TestTimeouts::large_test_timeout_ms()); |
308 return result == WAIT_OBJECT_0; | 308 return result == WAIT_OBJECT_0; |
309 } | 309 } |
OLD | NEW |