| 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 #import <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
| 6 | 6 |
| 7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/sys_string_conversions.h" | 10 #include "base/sys_string_conversions.h" |
| 11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
| 12 #include "base/values.h" | 12 #include "base/values.h" |
| 13 #import "chrome/browser/cocoa/extensions/extension_install_prompt_controller.h" | 13 #import "chrome/browser/cocoa/extensions/extension_install_prompt_controller.h" |
| 14 #include "chrome/browser/cocoa/browser_test_helper.h" | 14 #include "chrome/browser/cocoa/browser_test_helper.h" |
| 15 #import "chrome/browser/cocoa/cocoa_test_helper.h" | 15 #import "chrome/browser/cocoa/cocoa_test_helper.h" |
| 16 #import "chrome/browser/extensions/extension_install_ui.h" | 16 #import "chrome/browser/extensions/extension_install_ui.h" |
| 17 #include "chrome/common/chrome_paths.h" | 17 #include "chrome/common/chrome_paths.h" |
| 18 #include "chrome/common/extensions/extension.h" | 18 #include "chrome/common/extensions/extension.h" |
| 19 #include "chrome/common/json_value_serializer.h" | 19 #include "chrome/common/json_value_serializer.h" |
| 20 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
| 21 #import "testing/gtest_mac.h" |
| 21 #include "testing/platform_test.h" | 22 #include "testing/platform_test.h" |
| 22 #include "third_party/skia/include/core/SkBitmap.h" | 23 #include "third_party/skia/include/core/SkBitmap.h" |
| 23 #include "webkit/glue/image_decoder.h" | 24 #include "webkit/glue/image_decoder.h" |
| 24 | 25 |
| 25 | 26 |
| 26 // Base class for our tests. | 27 // Base class for our tests. |
| 27 class ExtensionInstallPromptControllerTest : public CocoaTest { | 28 class ExtensionInstallPromptControllerTest : public CocoaTest { |
| 28 public: | 29 public: |
| 29 ExtensionInstallPromptControllerTest() { | 30 ExtensionInstallPromptControllerTest() { |
| 30 PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir_); | 31 PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir_); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 initWithParentWindow:test_window() | 122 initWithParentWindow:test_window() |
| 122 profile:helper_.profile() | 123 profile:helper_.profile() |
| 123 extension:extension_.get() | 124 extension:extension_.get() |
| 124 delegate:delegate.get() | 125 delegate:delegate.get() |
| 125 icon:&icon_ | 126 icon:&icon_ |
| 126 warnings:warnings]); | 127 warnings:warnings]); |
| 127 | 128 |
| 128 [controller window]; // force nib load | 129 [controller window]; // force nib load |
| 129 | 130 |
| 130 // Test the right nib loaded. | 131 // Test the right nib loaded. |
| 131 EXPECT_TRUE([[controller windowNibName] isEqual:@"ExtensionInstallPrompt"]); | 132 EXPECT_NSEQ(@"ExtensionInstallPrompt", [controller windowNibName]); |
| 132 | 133 |
| 133 // Check all the controls. | 134 // Check all the controls. |
| 134 // Make sure everything is non-nil, and that the fields that are | 135 // Make sure everything is non-nil, and that the fields that are |
| 135 // auto-translated don't start with a caret (that would indicate that they | 136 // auto-translated don't start with a caret (that would indicate that they |
| 136 // were not translated). | 137 // were not translated). |
| 137 EXPECT_TRUE([controller iconView] != nil); | 138 EXPECT_TRUE([controller iconView] != nil); |
| 138 EXPECT_TRUE([[controller iconView] image] != nil); | 139 EXPECT_TRUE([[controller iconView] image] != nil); |
| 139 | 140 |
| 140 EXPECT_TRUE([controller titleField] != nil); | 141 EXPECT_TRUE([controller titleField] != nil); |
| 141 EXPECT_NE(0u, [[[controller titleField] stringValue] length]); | 142 EXPECT_NE(0u, [[[controller titleField] stringValue] length]); |
| 142 | 143 |
| 143 EXPECT_TRUE([controller subtitleField] != nil); | 144 EXPECT_TRUE([controller subtitleField] != nil); |
| 144 EXPECT_NE(0u, [[[controller subtitleField] stringValue] length]); | 145 EXPECT_NE(0u, [[[controller subtitleField] stringValue] length]); |
| 145 EXPECT_NE('^', [[[controller subtitleField] stringValue] characterAtIndex:0]); | 146 EXPECT_NE('^', [[[controller subtitleField] stringValue] characterAtIndex:0]); |
| 146 | 147 |
| 147 EXPECT_TRUE([controller warningsField] != nil); | 148 EXPECT_TRUE([controller warningsField] != nil); |
| 148 EXPECT_TRUE([[[controller warningsField] stringValue] | 149 EXPECT_NSEQ([[controller warningsField] stringValue], |
| 149 isEqual:(base::SysUTF16ToNSString(warnings[0]))]); | 150 base::SysUTF16ToNSString(warnings[0])); |
| 150 | 151 |
| 151 EXPECT_TRUE([controller warningsBox] != nil); | 152 EXPECT_TRUE([controller warningsBox] != nil); |
| 152 | 153 |
| 153 EXPECT_TRUE([controller cancelButton] != nil); | 154 EXPECT_TRUE([controller cancelButton] != nil); |
| 154 EXPECT_NE(0u, [[[controller cancelButton] stringValue] length]); | 155 EXPECT_NE(0u, [[[controller cancelButton] stringValue] length]); |
| 155 EXPECT_NE('^', [[[controller cancelButton] stringValue] characterAtIndex:0]); | 156 EXPECT_NE('^', [[[controller cancelButton] stringValue] characterAtIndex:0]); |
| 156 | 157 |
| 157 EXPECT_TRUE([controller okButton] != nil); | 158 EXPECT_TRUE([controller okButton] != nil); |
| 158 EXPECT_NE(0u, [[[controller okButton] stringValue] length]); | 159 EXPECT_NE(0u, [[[controller okButton] stringValue] length]); |
| 159 EXPECT_NE('^', [[[controller okButton] stringValue] characterAtIndex:0]); | 160 EXPECT_NE('^', [[[controller okButton] stringValue] characterAtIndex:0]); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 initWithParentWindow:test_window() | 264 initWithParentWindow:test_window() |
| 264 profile:helper_.profile() | 265 profile:helper_.profile() |
| 265 extension:extension_.get() | 266 extension:extension_.get() |
| 266 delegate:delegate.get() | 267 delegate:delegate.get() |
| 267 icon:&icon_ | 268 icon:&icon_ |
| 268 warnings:warnings]); | 269 warnings:warnings]); |
| 269 | 270 |
| 270 [controller window]; // force nib load | 271 [controller window]; // force nib load |
| 271 | 272 |
| 272 // Test the right nib loaded. | 273 // Test the right nib loaded. |
| 273 EXPECT_TRUE([[controller windowNibName] | 274 EXPECT_NSEQ(@"ExtensionInstallPromptNoWarnings", [controller windowNibName]); |
| 274 isEqual:@"ExtensionInstallPromptNoWarnings"]); | |
| 275 | 275 |
| 276 // Check all the controls. | 276 // Check all the controls. |
| 277 // In the skinny prompt, only the icon, title and buttons are non-nill. | 277 // In the skinny prompt, only the icon, title and buttons are non-nill. |
| 278 // Everything else is nil. | 278 // Everything else is nil. |
| 279 EXPECT_TRUE([controller iconView] != nil); | 279 EXPECT_TRUE([controller iconView] != nil); |
| 280 EXPECT_TRUE([[controller iconView] image] != nil); | 280 EXPECT_TRUE([[controller iconView] image] != nil); |
| 281 | 281 |
| 282 EXPECT_TRUE([controller titleField] != nil); | 282 EXPECT_TRUE([controller titleField] != nil); |
| 283 EXPECT_NE(0u, [[[controller titleField] stringValue] length]); | 283 EXPECT_NE(0u, [[[controller titleField] stringValue] length]); |
| 284 | 284 |
| 285 EXPECT_TRUE([controller cancelButton] != nil); | 285 EXPECT_TRUE([controller cancelButton] != nil); |
| 286 EXPECT_NE(0u, [[[controller cancelButton] stringValue] length]); | 286 EXPECT_NE(0u, [[[controller cancelButton] stringValue] length]); |
| 287 EXPECT_NE('^', [[[controller cancelButton] stringValue] characterAtIndex:0]); | 287 EXPECT_NE('^', [[[controller cancelButton] stringValue] characterAtIndex:0]); |
| 288 | 288 |
| 289 EXPECT_TRUE([controller okButton] != nil); | 289 EXPECT_TRUE([controller okButton] != nil); |
| 290 EXPECT_NE(0u, [[[controller okButton] stringValue] length]); | 290 EXPECT_NE(0u, [[[controller okButton] stringValue] length]); |
| 291 EXPECT_NE('^', [[[controller okButton] stringValue] characterAtIndex:0]); | 291 EXPECT_NE('^', [[[controller okButton] stringValue] characterAtIndex:0]); |
| 292 | 292 |
| 293 EXPECT_TRUE([controller subtitleField] == nil); | 293 EXPECT_TRUE([controller subtitleField] == nil); |
| 294 EXPECT_TRUE([controller warningsField] == nil); | 294 EXPECT_TRUE([controller warningsField] == nil); |
| 295 EXPECT_TRUE([controller warningsBox] == nil); | 295 EXPECT_TRUE([controller warningsBox] == nil); |
| 296 } | 296 } |
| OLD | NEW |