| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 path->assign(mini_installer_constants::kChromeDiffInstallerLocation); | 110 path->assign(mini_installer_constants::kChromeDiffInstallerLocation); |
| 111 file_util::AppendToPath(path, builds_list_size->name_); | 111 file_util::AppendToPath(path, builds_list_size->name_); |
| 112 if (channel_type == mini_installer_constants::kDevChannelBuild) | 112 if (channel_type == mini_installer_constants::kDevChannelBuild) |
| 113 file_util::AppendToPath(path, L"win"); | 113 file_util::AppendToPath(path, L"win"); |
| 114 std::wstring installer_path(path->c_str()); | 114 std::wstring installer_path(path->c_str()); |
| 115 file_util::AppendToPath(&installer_path, L"*.exe"); | 115 file_util::AppendToPath(&installer_path, L"*.exe"); |
| 116 if (!GetLatestFile(installer_path.c_str(), pattern, &exe_list)) { | 116 if (!GetLatestFile(installer_path.c_str(), pattern, &exe_list)) { |
| 117 ++builds_list_size; | 117 ++builds_list_size; |
| 118 } else { | 118 } else { |
| 119 file_util::AppendToPath(path, exe_list.at(0).name_.c_str()); | 119 file_util::AppendToPath(path, exe_list.at(0).name_.c_str()); |
| 120 if (!file_util::PathExists(*path)) { | 120 if (!file_util::PathExists(FilePath::FromWStringHack(*path))) { |
| 121 ++builds_list_size; | 121 ++builds_list_size; |
| 122 } else { | 122 } else { |
| 123 break; | 123 break; |
| 124 } | 124 } |
| 125 } | 125 } |
| 126 } | 126 } |
| 127 return (file_util::PathExists(path->c_str())); | 127 return file_util::PathExists(FilePath::FromWStringHack(*path)); |
| 128 } | 128 } |
| 129 | 129 |
| 130 // This method will get the latest installer filename from the directory. | 130 // This method will get the latest installer filename from the directory. |
| 131 bool MiniInstallerTestUtil::GetLatestFile(const wchar_t* file_name, | 131 bool MiniInstallerTestUtil::GetLatestFile(const wchar_t* file_name, |
| 132 const wchar_t* pattern, FileInfoList *file_details) { | 132 const wchar_t* pattern, FileInfoList *file_details) { |
| 133 WIN32_FIND_DATA find_file_data; | 133 WIN32_FIND_DATA find_file_data; |
| 134 HANDLE file_handle = FindFirstFile(file_name, &find_file_data); | 134 HANDLE file_handle = FindFirstFile(file_name, &find_file_data); |
| 135 if (file_handle == INVALID_HANDLE_VALUE) { | 135 if (file_handle == INVALID_HANDLE_VALUE) { |
| 136 LOG(INFO) << "Handle is invalid."; | 136 LOG(INFO) << "Handle is invalid."; |
| 137 return false; | 137 return false; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 if (channel_type == mini_installer_constants::kDevChannelBuild) | 195 if (channel_type == mini_installer_constants::kDevChannelBuild) |
| 196 file_util::AppendToPath(&diff_file, L"win"); | 196 file_util::AppendToPath(&diff_file, L"win"); |
| 197 previous->assign(diff_file); | 197 previous->assign(diff_file); |
| 198 file_util::AppendToPath(&diff_file, L"*.exe"); | 198 file_util::AppendToPath(&diff_file, L"*.exe"); |
| 199 FileInfoList directory_list; | 199 FileInfoList directory_list; |
| 200 if (!GetLatestFile(diff_file.c_str(), | 200 if (!GetLatestFile(diff_file.c_str(), |
| 201 mini_installer_constants::kFullInstallerPattern, | 201 mini_installer_constants::kFullInstallerPattern, |
| 202 &directory_list)) | 202 &directory_list)) |
| 203 return false; | 203 return false; |
| 204 file_util::AppendToPath(previous, directory_list.at(0).name_); | 204 file_util::AppendToPath(previous, directory_list.at(0).name_); |
| 205 return (file_util::PathExists(previous->c_str())); | 205 return file_util::PathExists(FilePath::FromWStringHack(*previous)); |
| 206 } | 206 } |
| 207 | 207 |
| 208 bool MiniInstallerTestUtil::GetStandaloneInstallerFileName( | 208 bool MiniInstallerTestUtil::GetStandaloneInstallerFileName( |
| 209 FileInfoList *file_name) { | 209 FileInfoList *file_name) { |
| 210 std::wstring standalone_installer( | 210 std::wstring standalone_installer( |
| 211 mini_installer_constants::kChromeStandAloneInstallerLocation); | 211 mini_installer_constants::kChromeStandAloneInstallerLocation); |
| 212 standalone_installer.append(L"*.exe"); | 212 standalone_installer.append(L"*.exe"); |
| 213 return (GetLatestFile(standalone_installer.c_str(), | 213 return GetLatestFile(standalone_installer.c_str(), |
| 214 mini_installer_constants::kUntaggedInstallerPattern, | 214 mini_installer_constants::kUntaggedInstallerPattern, |
| 215 file_name)); | 215 file_name); |
| 216 } | 216 } |
| 217 | 217 |
| 218 bool MiniInstallerTestUtil::GetStandaloneVersion( | 218 bool MiniInstallerTestUtil::GetStandaloneVersion( |
| 219 std::wstring* return_file_name) { | 219 std::wstring* return_file_name) { |
| 220 FileInfoList file_details; | 220 FileInfoList file_details; |
| 221 GetStandaloneInstallerFileName(&file_details); | 221 GetStandaloneInstallerFileName(&file_details); |
| 222 std::wstring file_name = file_details.at(0).name_; | 222 std::wstring file_name = file_details.at(0).name_; |
| 223 // Returned file name will have following convention: | 223 // Returned file name will have following convention: |
| 224 // ChromeStandaloneSetup_<build>_<patch>.exe | 224 // ChromeStandaloneSetup_<build>_<patch>.exe |
| 225 // Following code will extract build, patch details from the file | 225 // Following code will extract build, patch details from the file |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 (timer < 60000)) { | 274 (timer < 60000)) { |
| 275 PlatformThread::Sleep(200); | 275 PlatformThread::Sleep(200); |
| 276 timer = timer + 200; | 276 timer = timer + 200; |
| 277 } | 277 } |
| 278 } else { | 278 } else { |
| 279 if (base::GetProcessCount(process_name, NULL) != 0) | 279 if (base::GetProcessCount(process_name, NULL) != 0) |
| 280 return false; | 280 return false; |
| 281 } | 281 } |
| 282 return true; | 282 return true; |
| 283 } | 283 } |
| OLD | NEW |