Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/path_service.h" | 10 #include "base/path_service.h" |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 137 EXPECT_NE(0u, [[[controller titleField] stringValue] length]); | 137 EXPECT_NE(0u, [[[controller titleField] stringValue] length]); |
| 138 | 138 |
| 139 EXPECT_TRUE([controller subtitleField] != nil); | 139 EXPECT_TRUE([controller subtitleField] != nil); |
| 140 EXPECT_NE(0u, [[[controller subtitleField] stringValue] length]); | 140 EXPECT_NE(0u, [[[controller subtitleField] stringValue] length]); |
| 141 EXPECT_NE('^', [[[controller subtitleField] stringValue] characterAtIndex:0]); | 141 EXPECT_NE('^', [[[controller subtitleField] stringValue] characterAtIndex:0]); |
| 142 | 142 |
| 143 EXPECT_TRUE([controller warningsField] != nil); | 143 EXPECT_TRUE([controller warningsField] != nil); |
| 144 EXPECT_NSEQ([[controller warningsField] stringValue], | 144 EXPECT_NSEQ([[controller warningsField] stringValue], |
| 145 base::SysUTF16ToNSString(prompt.GetPermission(0))); | 145 base::SysUTF16ToNSString(prompt.GetPermission(0))); |
| 146 | 146 |
| 147 EXPECT_TRUE([controller warningsBox] != nil); | |
| 148 | |
| 149 EXPECT_TRUE([controller cancelButton] != nil); | 147 EXPECT_TRUE([controller cancelButton] != nil); |
| 150 EXPECT_NE(0u, [[[controller cancelButton] stringValue] length]); | 148 EXPECT_NE(0u, [[[controller cancelButton] stringValue] length]); |
| 151 EXPECT_NE('^', [[[controller cancelButton] stringValue] characterAtIndex:0]); | 149 EXPECT_NE('^', [[[controller cancelButton] stringValue] characterAtIndex:0]); |
| 152 | 150 |
| 153 EXPECT_TRUE([controller okButton] != nil); | 151 EXPECT_TRUE([controller okButton] != nil); |
| 154 EXPECT_NE(0u, [[[controller okButton] stringValue] length]); | 152 EXPECT_NE(0u, [[[controller okButton] stringValue] length]); |
| 155 EXPECT_NE('^', [[[controller okButton] stringValue] characterAtIndex:0]); | 153 EXPECT_NE('^', [[[controller okButton] stringValue] characterAtIndex:0]); |
| 156 | 154 |
| 157 // Test that cancel calls our delegate. | 155 // Test that cancel calls our delegate. |
| 158 [controller cancel:nil]; | 156 [controller cancel:nil]; |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 229 | 227 |
| 230 // Test control positioning. We don't test exact positioning because we don't | 228 // Test control positioning. We don't test exact positioning because we don't |
| 231 // want this to depend on string details and localization. But we do know the | 229 // want this to depend on string details and localization. But we do know the |
| 232 // relative effect that adding a second warning should have on the layout. | 230 // relative effect that adding a second warning should have on the layout. |
| 233 ASSERT_LT([[controller1 window] frame].size.height, | 231 ASSERT_LT([[controller1 window] frame].size.height, |
| 234 [[controller2 window] frame].size.height); | 232 [[controller2 window] frame].size.height); |
| 235 | 233 |
| 236 ASSERT_LT([[controller1 warningsField] frame].size.height, | 234 ASSERT_LT([[controller1 warningsField] frame].size.height, |
| 237 [[controller2 warningsField] frame].size.height); | 235 [[controller2 warningsField] frame].size.height); |
| 238 | 236 |
| 239 ASSERT_LT([[controller1 warningsBox] frame].size.height, | |
| 240 [[controller2 warningsBox] frame].size.height); | |
| 241 | |
| 242 ASSERT_EQ([[controller1 warningsBox] frame].origin.y, | |
| 243 [[controller2 warningsBox] frame].origin.y); | |
| 244 | |
| 245 ASSERT_LT([[controller1 subtitleField] frame].origin.y, | 237 ASSERT_LT([[controller1 subtitleField] frame].origin.y, |
| 246 [[controller2 subtitleField] frame].origin.y); | 238 [[controller2 subtitleField] frame].origin.y); |
| 247 | 239 |
| 248 ASSERT_LT([[controller1 titleField] frame].origin.y, | 240 ASSERT_LT([[controller1 titleField] frame].origin.y, |
| 249 [[controller2 titleField] frame].origin.y); | 241 [[controller2 titleField] frame].origin.y); |
| 250 } | 242 } |
| 251 | 243 |
| 252 // Test that we can load the skinny prompt correctly, and that the outlets are | 244 // Test that we can load the skinny prompt correctly, and that the outlets are |
| 253 // are hooked up. | 245 // are hooked up. |
| 254 TEST_F(ExtensionInstallDialogControllerTest, BasicsSkinny) { | 246 TEST_F(ExtensionInstallDialogControllerTest, BasicsSkinny) { |
| 255 scoped_ptr<MockExtensionInstallUIDelegate> delegate( | 247 scoped_ptr<MockExtensionInstallUIDelegate> delegate( |
| 256 new MockExtensionInstallUIDelegate); | 248 new MockExtensionInstallUIDelegate); |
| 257 | 249 |
| 258 // No warnings should trigger skinny prompt. | 250 // No warnings should trigger skinny prompt. |
| 259 ExtensionInstallUI::Prompt no_warnings_prompt( | 251 ExtensionInstallUI::Prompt no_warnings_prompt( |
| 260 ExtensionInstallUI::INSTALL_PROMPT); | 252 ExtensionInstallUI::INSTALL_PROMPT); |
| 261 | 253 |
| 262 std::vector<string16> warnings; | |
| 263 | |
| 264 scoped_nsobject<ExtensionInstallDialogController> | 254 scoped_nsobject<ExtensionInstallDialogController> |
| 265 controller([[ExtensionInstallDialogController alloc] | 255 controller([[ExtensionInstallDialogController alloc] |
| 266 initWithParentWindow:test_window() | 256 initWithParentWindow:test_window() |
| 267 profile:helper_.profile() | 257 profile:helper_.profile() |
| 268 extension:extension_.get() | 258 extension:extension_.get() |
| 269 delegate:delegate.get() | 259 delegate:delegate.get() |
| 270 icon:&icon_ | 260 icon:&icon_ |
| 271 prompt:no_warnings_prompt]); | 261 prompt:no_warnings_prompt]); |
| 272 | 262 |
| 273 [controller window]; // force nib load | 263 [controller window]; // force nib load |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 287 EXPECT_TRUE([controller cancelButton] != nil); | 277 EXPECT_TRUE([controller cancelButton] != nil); |
| 288 EXPECT_NE(0u, [[[controller cancelButton] stringValue] length]); | 278 EXPECT_NE(0u, [[[controller cancelButton] stringValue] length]); |
| 289 EXPECT_NE('^', [[[controller cancelButton] stringValue] characterAtIndex:0]); | 279 EXPECT_NE('^', [[[controller cancelButton] stringValue] characterAtIndex:0]); |
| 290 | 280 |
| 291 EXPECT_TRUE([controller okButton] != nil); | 281 EXPECT_TRUE([controller okButton] != nil); |
| 292 EXPECT_NE(0u, [[[controller okButton] stringValue] length]); | 282 EXPECT_NE(0u, [[[controller okButton] stringValue] length]); |
| 293 EXPECT_NE('^', [[[controller okButton] stringValue] characterAtIndex:0]); | 283 EXPECT_NE('^', [[[controller okButton] stringValue] characterAtIndex:0]); |
| 294 | 284 |
| 295 EXPECT_TRUE([controller subtitleField] == nil); | 285 EXPECT_TRUE([controller subtitleField] == nil); |
| 296 EXPECT_TRUE([controller warningsField] == nil); | 286 EXPECT_TRUE([controller warningsField] == nil); |
| 297 EXPECT_TRUE([controller warningsBox] == nil); | |
| 298 } | 287 } |
| 288 | |
| 289 | |
| 290 // Test that we can load the inline prompt correctly, and that the outlets are | |
| 291 // are hooked up. | |
| 292 TEST_F(ExtensionInstallDialogControllerTest, BasicsInline) { | |
| 293 scoped_ptr<MockExtensionInstallUIDelegate> delegate( | |
| 294 new MockExtensionInstallUIDelegate); | |
|
Nico
2011/09/05 22:59:17
Can't you stack-allocate this?
Mihai Parparita -not on Chrome
2011/09/06 00:54:11
Was just following the pattern in the rest of the
| |
| 295 | |
| 296 // No warnings should trigger skinny prompt. | |
| 297 ExtensionInstallUI::Prompt inline_prompt( | |
| 298 ExtensionInstallUI::INLINE_INSTALL_PROMPT); | |
| 299 inline_prompt.SetInlineInstallWebstoreData("1,000", 3.5, 200); | |
| 300 | |
| 301 scoped_nsobject<ExtensionInstallDialogController> | |
| 302 controller([[ExtensionInstallDialogController alloc] | |
| 303 initWithParentWindow:test_window() | |
| 304 profile:helper_.profile() | |
| 305 extension:extension_.get() | |
| 306 delegate:delegate.get() | |
| 307 icon:&icon_ | |
| 308 prompt:inline_prompt]); | |
| 309 | |
| 310 [controller window]; // force nib load | |
| 311 | |
| 312 // Test the right nib loaded. | |
| 313 EXPECT_NSEQ(@"ExtensionInstallPromptInline", [controller windowNibName]); | |
| 314 | |
| 315 // Check all the controls. | |
| 316 EXPECT_TRUE([controller iconView] != nil); | |
| 317 EXPECT_TRUE([[controller iconView] image] != nil); | |
| 318 | |
| 319 EXPECT_TRUE([controller titleField] != nil); | |
| 320 EXPECT_NE(0u, [[[controller titleField] stringValue] length]); | |
| 321 | |
| 322 EXPECT_TRUE([controller cancelButton] != nil); | |
| 323 EXPECT_NE(0u, [[[controller cancelButton] stringValue] length]); | |
| 324 EXPECT_NE('^', [[[controller cancelButton] stringValue] characterAtIndex:0]); | |
| 325 | |
| 326 EXPECT_TRUE([controller okButton] != nil); | |
| 327 EXPECT_NE(0u, [[[controller okButton] stringValue] length]); | |
| 328 EXPECT_NE('^', [[[controller okButton] stringValue] characterAtIndex:0]); | |
| 329 | |
| 330 EXPECT_TRUE([controller ratingStars] != nil); | |
| 331 EXPECT_EQ(5u, [[[controller ratingStars] subviews] count]); | |
| 332 | |
| 333 EXPECT_TRUE([controller ratingCountField] != nil); | |
| 334 EXPECT_NE(0u, [[[controller ratingCountField] stringValue] length]); | |
| 335 | |
| 336 EXPECT_TRUE([controller userCountField] != nil); | |
| 337 EXPECT_NE(0u, [[[controller userCountField] stringValue] length]); | |
| 338 | |
| 339 // Though we have no permissions warnings, these should still be hooked up, | |
| 340 // just invisible | |
|
Nico
2011/09/05 22:59:17
trailing .
Mihai Parparita -not on Chrome
2011/09/06 00:54:11
Done.
| |
| 341 EXPECT_TRUE([controller subtitleField] != nil); | |
| 342 EXPECT_TRUE([[controller subtitleField] isHidden]); | |
| 343 EXPECT_TRUE([controller warningsField] != nil); | |
| 344 EXPECT_TRUE([[controller warningsField] isHidden]); | |
| 345 EXPECT_TRUE([controller warningsSeparator] != nil); | |
| 346 EXPECT_TRUE([[controller warningsSeparator] isHidden]); | |
| 347 } | |
| OLD | NEW |