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 "chrome/installer/util/install_util.h" | 5 #include "chrome/installer/util/install_util.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/base_paths.h" | 10 #include "base/base_paths.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 TEST_F(InstallUtilTest, ComposeCommandLine) { | 57 TEST_F(InstallUtilTest, ComposeCommandLine) { |
58 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); | 58 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); |
59 | 59 |
60 std::pair<std::wstring, std::wstring> params[] = { | 60 std::pair<std::wstring, std::wstring> params[] = { |
61 std::make_pair(std::wstring(L""), std::wstring(L"")), | 61 std::make_pair(std::wstring(L""), std::wstring(L"")), |
62 std::make_pair(std::wstring(L""), std::wstring(L"--do-something --silly")), | 62 std::make_pair(std::wstring(L""), std::wstring(L"--do-something --silly")), |
63 std::make_pair(std::wstring(L"spam.exe"), std::wstring(L"")), | 63 std::make_pair(std::wstring(L"spam.exe"), std::wstring(L"")), |
64 std::make_pair(std::wstring(L"spam.exe"), | 64 std::make_pair(std::wstring(L"spam.exe"), |
65 std::wstring(L"--do-something --silly")), | 65 std::wstring(L"--do-something --silly")), |
66 }; | 66 }; |
67 for (int i = 0; i < arraysize(params); ++i) { | 67 for (std::pair<std::wstring, std::wstring>& param : params) { |
68 std::pair<std::wstring, std::wstring>& param = params[i]; | |
69 InstallUtil::ComposeCommandLine(param.first, param.second, &command_line); | 68 InstallUtil::ComposeCommandLine(param.first, param.second, &command_line); |
70 EXPECT_EQ(param.first, command_line.GetProgram().value()); | 69 EXPECT_EQ(param.first, command_line.GetProgram().value()); |
71 if (param.second.empty()) { | 70 if (param.second.empty()) { |
72 EXPECT_TRUE(command_line.GetSwitches().empty()); | 71 EXPECT_TRUE(command_line.GetSwitches().empty()); |
73 } else { | 72 } else { |
74 EXPECT_EQ(2U, command_line.GetSwitches().size()); | 73 EXPECT_EQ(2U, command_line.GetSwitches().size()); |
75 EXPECT_TRUE(command_line.HasSwitch("do-something")); | 74 EXPECT_TRUE(command_line.HasSwitch("do-something")); |
76 EXPECT_TRUE(command_line.HasSwitch("silly")); | 75 EXPECT_TRUE(command_line.HasSwitch("silly")); |
77 } | 76 } |
78 } | 77 } |
79 } | 78 } |
80 | 79 |
81 TEST_F(InstallUtilTest, GetCurrentDate) { | 80 TEST_F(InstallUtilTest, GetCurrentDate) { |
82 std::wstring date(InstallUtil::GetCurrentDate()); | 81 std::wstring date(InstallUtil::GetCurrentDate()); |
83 EXPECT_EQ(8, date.length()); | 82 EXPECT_EQ(8u, date.length()); |
84 if (date.length() == 8) { | 83 if (date.length() == 8) { |
85 // For an invalid date value, SystemTimeToFileTime will fail. | 84 // For an invalid date value, SystemTimeToFileTime will fail. |
86 // We use this to validate that we have a correct date string. | 85 // We use this to validate that we have a correct date string. |
87 SYSTEMTIME systime = {0}; | 86 SYSTEMTIME systime = {0}; |
88 FILETIME ft = {0}; | 87 FILETIME ft = {0}; |
89 // Just to make sure our assumption holds. | 88 // Just to make sure our assumption holds. |
90 EXPECT_FALSE(SystemTimeToFileTime(&systime, &ft)); | 89 EXPECT_FALSE(SystemTimeToFileTime(&systime, &ft)); |
91 // Now fill in the values from our string. | 90 // Now fill in the values from our string. |
92 systime.wYear = _wtoi(date.substr(0, 4).c_str()); | 91 systime.wYear = _wtoi(date.substr(0, 4).c_str()); |
93 systime.wMonth = _wtoi(date.substr(4, 2).c_str()); | 92 systime.wMonth = _wtoi(date.substr(4, 2).c_str()); |
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
475 #if defined(_WIN64) | 474 #if defined(_WIN64) |
476 const int kOtherProgramFilesKey = base::DIR_PROGRAM_FILES; | 475 const int kOtherProgramFilesKey = base::DIR_PROGRAM_FILES; |
477 base::ScopedPathOverride other_program_files_override(kOtherProgramFilesKey); | 476 base::ScopedPathOverride other_program_files_override(kOtherProgramFilesKey); |
478 ASSERT_TRUE(PathService::Get(kOtherProgramFilesKey, &some_exe)); | 477 ASSERT_TRUE(PathService::Get(kOtherProgramFilesKey, &some_exe)); |
479 some_exe = some_exe.AppendASCII("Company") | 478 some_exe = some_exe.AppendASCII("Company") |
480 .AppendASCII("Product") | 479 .AppendASCII("Product") |
481 .AppendASCII("product.exe"); | 480 .AppendASCII("product.exe"); |
482 EXPECT_TRUE(InstallUtil::IsPerUserInstall(some_exe)); | 481 EXPECT_TRUE(InstallUtil::IsPerUserInstall(some_exe)); |
483 #endif // defined(_WIN64) | 482 #endif // defined(_WIN64) |
484 } | 483 } |
OLD | NEW |