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 // Unit tests for utilities related to installation of the CEEE. | 5 // Unit tests for utilities related to installation of the CEEE. |
6 | 6 |
7 #include "ceee/common/install_utils.h" | 7 #include "ceee/common/install_utils.h" |
8 | 8 |
9 #include "base/base_paths.h" | 9 #include "base/base_paths.h" |
10 #include "ceee/testing/utils/mock_win32.h" | 10 #include "ceee/testing/utils/mock_win32.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 testing::PathServiceOverrider override(base::FILE_EXE, | 38 testing::PathServiceOverrider override(base::FILE_EXE, |
39 FilePath(L"c:\\windows\\regsvr32.exe\\foobar.exe")); | 39 FilePath(L"c:\\windows\\regsvr32.exe\\foobar.exe")); |
40 ASSERT_FALSE(ceee_install_utils::ShouldRegisterCeee()); | 40 ASSERT_FALSE(ceee_install_utils::ShouldRegisterCeee()); |
41 ASSERT_FALSE(ceee_install_utils::ShouldRegisterFfCeee()); | 41 ASSERT_FALSE(ceee_install_utils::ShouldRegisterFfCeee()); |
42 } | 42 } |
43 | 43 |
44 TEST(ShouldRegisterCeee, TrueIfBothFlagsPresent) { | 44 TEST(ShouldRegisterCeee, TrueIfBothFlagsPresent) { |
45 testing::MockKernel32 kernel32; | 45 testing::MockKernel32 kernel32; |
46 EXPECT_CALL(kernel32, GetCommandLine()).WillOnce( | 46 EXPECT_CALL(kernel32, GetCommandLine()).WillOnce( |
47 Return(const_cast<wchar_t*>( | 47 Return(const_cast<wchar_t*>( |
48 L"mini_installer.exe --enable-ceee --chrome-frame"))); | 48 L"mini_installer.exe --ceee --chrome-frame"))); |
49 ASSERT_TRUE(ceee_install_utils::ShouldRegisterCeee()); | 49 ASSERT_TRUE(ceee_install_utils::ShouldRegisterCeee()); |
50 } | 50 } |
51 | 51 |
52 TEST(ShouldRegisterFfCeee, TrueIfAllFlagsPresent) { | 52 TEST(ShouldRegisterFfCeee, TrueIfAllFlagsPresent) { |
53 testing::MockKernel32 kernel32; | 53 testing::MockKernel32 kernel32; |
54 EXPECT_CALL(kernel32, GetCommandLine()).Times(2).WillRepeatedly( | 54 EXPECT_CALL(kernel32, GetCommandLine()).Times(2).WillRepeatedly( |
55 Return(const_cast<wchar_t*>( | 55 Return(const_cast<wchar_t*>( |
56 L"mini_installer.exe --enable-ceee --chrome-frame " | 56 L"mini_installer.exe --ceee --chrome-frame " |
57 L"--enable-ff-ceee"))); | 57 L"--enable-ff-ceee"))); |
58 EXPECT_TRUE(ceee_install_utils::ShouldRegisterFfCeee()); | 58 EXPECT_TRUE(ceee_install_utils::ShouldRegisterFfCeee()); |
59 // Check this as well just in case. | 59 // Check this as well just in case. |
60 ASSERT_TRUE(ceee_install_utils::ShouldRegisterCeee()); | 60 ASSERT_TRUE(ceee_install_utils::ShouldRegisterCeee()); |
61 } | 61 } |
62 | 62 |
63 TEST(ShouldRegisterCeee, FalseIfOneFlagPresent) { | 63 TEST(ShouldRegisterCeee, FalseIfOneFlagPresent) { |
64 testing::MockKernel32 kernel32; | 64 testing::MockKernel32 kernel32; |
65 EXPECT_CALL(kernel32, GetCommandLine()) | 65 EXPECT_CALL(kernel32, GetCommandLine()) |
66 .WillOnce(Return(const_cast<wchar_t*>( | 66 .WillOnce(Return(const_cast<wchar_t*>( |
67 L"mini_installer.exe --enable-ceee"))) | 67 L"mini_installer.exe --ceee"))) |
68 .WillOnce(Return(const_cast<wchar_t*>( | 68 .WillOnce(Return(const_cast<wchar_t*>( |
69 L"mini_installer.exe --chrome-frame"))); | 69 L"mini_installer.exe --chrome-frame"))); |
70 ASSERT_FALSE(ceee_install_utils::ShouldRegisterCeee()); | 70 ASSERT_FALSE(ceee_install_utils::ShouldRegisterCeee()); |
71 ASSERT_FALSE(ceee_install_utils::ShouldRegisterCeee()); | 71 ASSERT_FALSE(ceee_install_utils::ShouldRegisterCeee()); |
72 } | 72 } |
73 | 73 |
74 TEST(ShouldRegisterFfCeee, FalseIfOnlyTwoFlagsPresent) { | 74 TEST(ShouldRegisterFfCeee, FalseIfOnlyTwoFlagsPresent) { |
75 testing::MockKernel32 kernel32; | 75 testing::MockKernel32 kernel32; |
76 EXPECT_CALL(kernel32, GetCommandLine()) | 76 EXPECT_CALL(kernel32, GetCommandLine()) |
77 .WillOnce(Return(const_cast<wchar_t*>( | 77 .WillOnce(Return(const_cast<wchar_t*>( |
78 L"mini_installer.exe --enable-ceee --chrome-frame"))) | 78 L"mini_installer.exe --ceee --chrome-frame"))) |
79 .WillOnce(Return(const_cast<wchar_t*>( | 79 .WillOnce(Return(const_cast<wchar_t*>( |
80 L"mini_installer.exe --chrome-frame --enable-ff-ceee"))) | 80 L"mini_installer.exe --chrome-frame --enable-ff-ceee"))) |
81 .WillOnce(Return(const_cast<wchar_t*>( | 81 .WillOnce(Return(const_cast<wchar_t*>( |
82 L"mini_installer.exe --enable-ceee --enable-ff-ceee"))); | 82 L"mini_installer.exe --ceee --enable-ff-ceee"))); |
83 ASSERT_FALSE(ceee_install_utils::ShouldRegisterFfCeee()); | 83 ASSERT_FALSE(ceee_install_utils::ShouldRegisterFfCeee()); |
84 ASSERT_FALSE(ceee_install_utils::ShouldRegisterFfCeee()); | 84 ASSERT_FALSE(ceee_install_utils::ShouldRegisterFfCeee()); |
85 ASSERT_FALSE(ceee_install_utils::ShouldRegisterFfCeee()); | 85 ASSERT_FALSE(ceee_install_utils::ShouldRegisterFfCeee()); |
86 } | 86 } |
87 | 87 |
88 TEST(ShouldRegisterCeee, FalseIfInvertedFlagPresent) { | 88 TEST(ShouldRegisterCeee, FalseIfInvertedFlagPresent) { |
89 testing::MockKernel32 kernel32; | 89 testing::MockKernel32 kernel32; |
90 EXPECT_CALL(kernel32, GetCommandLine()).WillOnce( | 90 EXPECT_CALL(kernel32, GetCommandLine()).WillOnce( |
91 Return(const_cast<wchar_t*>( | 91 Return(const_cast<wchar_t*>( |
92 L"mini_installer.exe --noenable-ceee --chrome-frame"))); | 92 L"mini_installer.exe --noenable-ceee --chrome-frame"))); |
93 ASSERT_FALSE(ceee_install_utils::ShouldRegisterCeee()); | 93 ASSERT_FALSE(ceee_install_utils::ShouldRegisterCeee()); |
94 } | 94 } |
95 | 95 |
96 TEST(ShouldRegisterFfCeee, FalseIfInvertedFlagPresent) { | 96 TEST(ShouldRegisterFfCeee, FalseIfInvertedFlagPresent) { |
97 testing::MockKernel32 kernel32; | 97 testing::MockKernel32 kernel32; |
98 EXPECT_CALL(kernel32, GetCommandLine()).WillOnce( | 98 EXPECT_CALL(kernel32, GetCommandLine()).WillOnce( |
99 Return(const_cast<wchar_t*>( | 99 Return(const_cast<wchar_t*>( |
100 L"mini_installer.exe --enable-ceee --noenable-ff-ceee " | 100 L"mini_installer.exe --ceee --noenable-ff-ceee " |
101 L"--chrome-frame"))); | 101 L"--chrome-frame"))); |
102 ASSERT_FALSE(ceee_install_utils::ShouldRegisterFfCeee()); | 102 ASSERT_FALSE(ceee_install_utils::ShouldRegisterFfCeee()); |
103 } | 103 } |
104 | 104 |
105 TEST(ShouldRegisterCeee, FalseIfBogusFlagPresent) { | 105 TEST(ShouldRegisterCeee, FalseIfBogusFlagPresent) { |
106 testing::MockKernel32 kernel32; | 106 testing::MockKernel32 kernel32; |
107 EXPECT_CALL(kernel32, GetCommandLine()).WillOnce( | 107 EXPECT_CALL(kernel32, GetCommandLine()).WillOnce( |
108 Return(const_cast<wchar_t*>( | 108 Return(const_cast<wchar_t*>( |
109 L"mini_installer.exe --enable-ceeez --chrome-frame"))); | 109 L"mini_installer.exe --enable-ceeez --chrome-frame"))); |
110 ASSERT_FALSE(ceee_install_utils::ShouldRegisterCeee()); | 110 ASSERT_FALSE(ceee_install_utils::ShouldRegisterCeee()); |
111 } | 111 } |
112 | 112 |
113 TEST(ShouldRegisterFfCeee, FalseIfBogusFlagPresent) { | 113 TEST(ShouldRegisterFfCeee, FalseIfBogusFlagPresent) { |
114 testing::MockKernel32 kernel32; | 114 testing::MockKernel32 kernel32; |
115 EXPECT_CALL(kernel32, GetCommandLine()).WillOnce( | 115 EXPECT_CALL(kernel32, GetCommandLine()).WillOnce( |
116 Return(const_cast<wchar_t*>( | 116 Return(const_cast<wchar_t*>( |
117 L"mini_installer.exe --enable-ceee --enable-ff-ceeez " | 117 L"mini_installer.exe --ceee --enable-ff-ceeez " |
118 L"--chrome-frame"))); | 118 L"--chrome-frame"))); |
119 ASSERT_FALSE(ceee_install_utils::ShouldRegisterFfCeee()); | 119 ASSERT_FALSE(ceee_install_utils::ShouldRegisterFfCeee()); |
120 } | 120 } |
121 | 121 |
122 namespace dll_register_server_test { | 122 namespace dll_register_server_test { |
123 | 123 |
124 // Gets set to true by DllRegisterServer. | 124 // Gets set to true by DllRegisterServer. |
125 bool registration_was_done = false; | 125 bool registration_was_done = false; |
126 | 126 |
127 // This is for unit testing only. Because we're in an anonymous namespace | 127 // This is for unit testing only. Because we're in an anonymous namespace |
(...skipping 23 matching lines...) Expand all Loading... |
151 | 151 |
152 registration_was_done = false; | 152 registration_was_done = false; |
153 DllRegisterServer(); | 153 DllRegisterServer(); |
154 ASSERT_TRUE(registration_was_done); | 154 ASSERT_TRUE(registration_was_done); |
155 } | 155 } |
156 | 156 |
157 } // namespace dll_register_server_test | 157 } // namespace dll_register_server_test |
158 | 158 |
159 | 159 |
160 } // namespace | 160 } // namespace |
OLD | NEW |