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 #import <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
6 | 6 |
7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/json/json_file_value_serializer.h" | 10 #include "base/json/json_file_value_serializer.h" |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 protected: | 102 protected: |
103 int proceed_count_; | 103 int proceed_count_; |
104 int abort_count_; | 104 int abort_count_; |
105 }; | 105 }; |
106 | 106 |
107 // Test that we can load the two kinds of prompts correctly, that the outlets | 107 // Test that we can load the two kinds of prompts correctly, that the outlets |
108 // are hooked up, and that the dialog calls cancel when cancel is pressed. | 108 // are hooked up, and that the dialog calls cancel when cancel is pressed. |
109 TEST_F(ExtensionInstallDialogControllerTest, BasicsNormalCancel) { | 109 TEST_F(ExtensionInstallDialogControllerTest, BasicsNormalCancel) { |
110 MockExtensionInstallPromptDelegate delegate; | 110 MockExtensionInstallPromptDelegate delegate; |
111 | 111 |
112 ExtensionInstallPrompt::Prompt prompt(ExtensionInstallPrompt::INSTALL_PROMPT); | 112 ExtensionInstallPrompt::Prompt prompt( |
| 113 NULL, ExtensionInstallPrompt::INSTALL_PROMPT); |
| 114 |
113 std::vector<string16> permissions; | 115 std::vector<string16> permissions; |
114 permissions.push_back(UTF8ToUTF16("warning 1")); | 116 permissions.push_back(UTF8ToUTF16("warning 1")); |
115 prompt.SetPermissions(permissions); | 117 prompt.SetPermissions(permissions); |
116 prompt.set_extension(extension_.get()); | 118 prompt.set_extension(extension_.get()); |
117 prompt.set_icon(icon_); | 119 prompt.set_icon(icon_); |
118 | 120 |
119 scoped_nsobject<ExtensionInstallDialogController> | 121 scoped_nsobject<ExtensionInstallDialogController> |
120 controller([[ExtensionInstallDialogController alloc] | 122 controller([[ExtensionInstallDialogController alloc] |
121 initWithParentWindow:test_window() | 123 initWithParentWindow:test_window() |
122 navigator:browser() | 124 navigator:browser() |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 [controller cancel:nil]; | 160 [controller cancel:nil]; |
159 EXPECT_EQ(1, delegate.abort_count()); | 161 EXPECT_EQ(1, delegate.abort_count()); |
160 EXPECT_EQ(0, delegate.proceed_count()); | 162 EXPECT_EQ(0, delegate.proceed_count()); |
161 } | 163 } |
162 | 164 |
163 | 165 |
164 TEST_F(ExtensionInstallDialogControllerTest, BasicsNormalOK) { | 166 TEST_F(ExtensionInstallDialogControllerTest, BasicsNormalOK) { |
165 MockExtensionInstallPromptDelegate delegate; | 167 MockExtensionInstallPromptDelegate delegate; |
166 | 168 |
167 ExtensionInstallPrompt::Prompt prompt( | 169 ExtensionInstallPrompt::Prompt prompt( |
168 ExtensionInstallPrompt::INSTALL_PROMPT); | 170 NULL, ExtensionInstallPrompt::INSTALL_PROMPT); |
169 std::vector<string16> permissions; | 171 std::vector<string16> permissions; |
170 permissions.push_back(UTF8ToUTF16("warning 1")); | 172 permissions.push_back(UTF8ToUTF16("warning 1")); |
171 prompt.SetPermissions(permissions); | 173 prompt.SetPermissions(permissions); |
172 prompt.set_extension(extension_.get()); | 174 prompt.set_extension(extension_.get()); |
173 prompt.set_icon(icon_); | 175 prompt.set_icon(icon_); |
174 | 176 |
175 scoped_nsobject<ExtensionInstallDialogController> | 177 scoped_nsobject<ExtensionInstallDialogController> |
176 controller([[ExtensionInstallDialogController alloc] | 178 controller([[ExtensionInstallDialogController alloc] |
177 initWithParentWindow:test_window() | 179 initWithParentWindow:test_window() |
178 navigator:browser() | 180 navigator:browser() |
179 delegate:&delegate | 181 delegate:&delegate |
180 prompt:prompt]); | 182 prompt:prompt]); |
181 | 183 |
182 [controller window]; // force nib load | 184 [controller window]; // force nib load |
183 [controller ok:nil]; | 185 [controller ok:nil]; |
184 | 186 |
185 EXPECT_EQ(0, delegate.abort_count()); | 187 EXPECT_EQ(0, delegate.abort_count()); |
186 EXPECT_EQ(1, delegate.proceed_count()); | 188 EXPECT_EQ(1, delegate.proceed_count()); |
187 } | 189 } |
188 | 190 |
189 // Test that controls get repositioned when there are two warnings vs one | 191 // Test that controls get repositioned when there are two warnings vs one |
190 // warning. | 192 // warning. |
191 TEST_F(ExtensionInstallDialogControllerTest, MultipleWarnings) { | 193 TEST_F(ExtensionInstallDialogControllerTest, MultipleWarnings) { |
192 MockExtensionInstallPromptDelegate delegate1; | 194 MockExtensionInstallPromptDelegate delegate1; |
193 MockExtensionInstallPromptDelegate delegate2; | 195 MockExtensionInstallPromptDelegate delegate2; |
194 | 196 |
195 ExtensionInstallPrompt::Prompt one_warning_prompt( | 197 ExtensionInstallPrompt::Prompt one_warning_prompt( |
196 ExtensionInstallPrompt::INSTALL_PROMPT); | 198 NULL, ExtensionInstallPrompt::INSTALL_PROMPT); |
197 std::vector<string16> permissions; | 199 std::vector<string16> permissions; |
198 permissions.push_back(UTF8ToUTF16("warning 1")); | 200 permissions.push_back(UTF8ToUTF16("warning 1")); |
199 one_warning_prompt.SetPermissions(permissions); | 201 one_warning_prompt.SetPermissions(permissions); |
200 one_warning_prompt.set_extension(extension_.get()); | 202 one_warning_prompt.set_extension(extension_.get()); |
201 one_warning_prompt.set_icon(icon_); | 203 one_warning_prompt.set_icon(icon_); |
202 | 204 |
203 ExtensionInstallPrompt::Prompt two_warnings_prompt( | 205 ExtensionInstallPrompt::Prompt two_warnings_prompt( |
204 ExtensionInstallPrompt::INSTALL_PROMPT); | 206 NULL, ExtensionInstallPrompt::INSTALL_PROMPT); |
205 permissions.push_back(UTF8ToUTF16("warning 2")); | 207 permissions.push_back(UTF8ToUTF16("warning 2")); |
206 two_warnings_prompt.SetPermissions(permissions); | 208 two_warnings_prompt.SetPermissions(permissions); |
207 two_warnings_prompt.set_extension(extension_.get()); | 209 two_warnings_prompt.set_extension(extension_.get()); |
208 two_warnings_prompt.set_icon(icon_); | 210 two_warnings_prompt.set_icon(icon_); |
209 | 211 |
210 scoped_nsobject<ExtensionInstallDialogController> | 212 scoped_nsobject<ExtensionInstallDialogController> |
211 controller1([[ExtensionInstallDialogController alloc] | 213 controller1([[ExtensionInstallDialogController alloc] |
212 initWithParentWindow:test_window() | 214 initWithParentWindow:test_window() |
213 navigator:browser() | 215 navigator:browser() |
214 delegate:&delegate1 | 216 delegate:&delegate1 |
(...skipping 26 matching lines...) Expand all Loading... |
241 [[controller2 titleField] frame].origin.y); | 243 [[controller2 titleField] frame].origin.y); |
242 } | 244 } |
243 | 245 |
244 // Test that we can load the skinny prompt correctly, and that the outlets are | 246 // Test that we can load the skinny prompt correctly, and that the outlets are |
245 // are hooked up. | 247 // are hooked up. |
246 TEST_F(ExtensionInstallDialogControllerTest, BasicsSkinny) { | 248 TEST_F(ExtensionInstallDialogControllerTest, BasicsSkinny) { |
247 MockExtensionInstallPromptDelegate delegate; | 249 MockExtensionInstallPromptDelegate delegate; |
248 | 250 |
249 // No warnings should trigger skinny prompt. | 251 // No warnings should trigger skinny prompt. |
250 ExtensionInstallPrompt::Prompt no_warnings_prompt( | 252 ExtensionInstallPrompt::Prompt no_warnings_prompt( |
251 ExtensionInstallPrompt::INSTALL_PROMPT); | 253 NULL, ExtensionInstallPrompt::INSTALL_PROMPT); |
252 no_warnings_prompt.set_extension(extension_.get()); | 254 no_warnings_prompt.set_extension(extension_.get()); |
253 no_warnings_prompt.set_icon(icon_); | 255 no_warnings_prompt.set_icon(icon_); |
254 | 256 |
255 scoped_nsobject<ExtensionInstallDialogController> | 257 scoped_nsobject<ExtensionInstallDialogController> |
256 controller([[ExtensionInstallDialogController alloc] | 258 controller([[ExtensionInstallDialogController alloc] |
257 initWithParentWindow:test_window() | 259 initWithParentWindow:test_window() |
258 navigator:browser() | 260 navigator:browser() |
259 delegate:&delegate | 261 delegate:&delegate |
260 prompt:no_warnings_prompt]); | 262 prompt:no_warnings_prompt]); |
261 | 263 |
(...skipping 24 matching lines...) Expand all Loading... |
286 } | 288 } |
287 | 289 |
288 | 290 |
289 // Test that we can load the inline prompt correctly, and that the outlets are | 291 // Test that we can load the inline prompt correctly, and that the outlets are |
290 // are hooked up. | 292 // are hooked up. |
291 TEST_F(ExtensionInstallDialogControllerTest, BasicsInline) { | 293 TEST_F(ExtensionInstallDialogControllerTest, BasicsInline) { |
292 MockExtensionInstallPromptDelegate delegate; | 294 MockExtensionInstallPromptDelegate delegate; |
293 | 295 |
294 // No warnings should trigger skinny prompt. | 296 // No warnings should trigger skinny prompt. |
295 ExtensionInstallPrompt::Prompt inline_prompt( | 297 ExtensionInstallPrompt::Prompt inline_prompt( |
296 ExtensionInstallPrompt::INLINE_INSTALL_PROMPT); | 298 NULL, ExtensionInstallPrompt::INLINE_INSTALL_PROMPT); |
297 inline_prompt.SetInlineInstallWebstoreData("1,000", 3.5, 200); | 299 inline_prompt.SetInlineInstallWebstoreData("1,000", 3.5, 200); |
298 inline_prompt.set_extension(extension_.get()); | 300 inline_prompt.set_extension(extension_.get()); |
299 inline_prompt.set_icon(icon_); | 301 inline_prompt.set_icon(icon_); |
300 | 302 |
301 scoped_nsobject<ExtensionInstallDialogController> | 303 scoped_nsobject<ExtensionInstallDialogController> |
302 controller([[ExtensionInstallDialogController alloc] | 304 controller([[ExtensionInstallDialogController alloc] |
303 initWithParentWindow:test_window() | 305 initWithParentWindow:test_window() |
304 navigator:browser() | 306 navigator:browser() |
305 delegate:&delegate | 307 delegate:&delegate |
306 prompt:inline_prompt]); | 308 prompt:inline_prompt]); |
(...skipping 29 matching lines...) Expand all Loading... |
336 | 338 |
337 // Though we have no permissions warnings, these should still be hooked up, | 339 // Though we have no permissions warnings, these should still be hooked up, |
338 // just invisible. | 340 // just invisible. |
339 EXPECT_TRUE([controller subtitleField] != nil); | 341 EXPECT_TRUE([controller subtitleField] != nil); |
340 EXPECT_TRUE([[controller subtitleField] isHidden]); | 342 EXPECT_TRUE([[controller subtitleField] isHidden]); |
341 EXPECT_TRUE([controller warningsField] != nil); | 343 EXPECT_TRUE([controller warningsField] != nil); |
342 EXPECT_TRUE([[controller warningsField] isHidden]); | 344 EXPECT_TRUE([[controller warningsField] isHidden]); |
343 EXPECT_TRUE([controller warningsSeparator] != nil); | 345 EXPECT_TRUE([controller warningsSeparator] != nil); |
344 EXPECT_TRUE([[controller warningsSeparator] isHidden]); | 346 EXPECT_TRUE([[controller warningsSeparator] isHidden]); |
345 } | 347 } |
OLD | NEW |