| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #import "base/scoped_nsobject.h" | 7 #import "base/scoped_nsobject.h" |
| 8 #import "chrome/app/keystone_glue.h" | 8 #import "chrome/app/keystone_glue.h" |
| 9 #import "chrome/browser/cocoa/about_window_controller.h" | 9 #import "chrome/browser/cocoa/about_window_controller.h" |
| 10 #include "chrome/browser/cocoa/browser_test_helper.h" | 10 #include "chrome/browser/cocoa/browser_test_helper.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 if (version) { | 24 if (version) { |
| 25 [dictionary setObject:version forKey:kAutoupdateStatusVersion]; | 25 [dictionary setObject:version forKey:kAutoupdateStatusVersion]; |
| 26 } | 26 } |
| 27 | 27 |
| 28 NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; | 28 NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; |
| 29 [center postNotificationName:kAutoupdateStatusNotification | 29 [center postNotificationName:kAutoupdateStatusNotification |
| 30 object:nil | 30 object:nil |
| 31 userInfo:dictionary]; | 31 userInfo:dictionary]; |
| 32 } | 32 } |
| 33 | 33 |
| 34 class AboutWindowControllerTest : public PlatformTest { | 34 class AboutWindowControllerTest : public CocoaTest { |
| 35 public: | 35 public: |
| 36 virtual void SetUp() { | 36 virtual void SetUp() { |
| 37 PlatformTest::SetUp(); | 37 CocoaTest::SetUp(); |
| 38 about_window_controller_.reset([[AboutWindowController alloc] | 38 about_window_controller_ = |
| 39 initWithProfile:nil]); | 39 [[AboutWindowController alloc] initWithProfile:nil]; |
| 40 // make sure the nib is loaded | 40 EXPECT_TRUE([about_window_controller_ window]); |
| 41 [about_window_controller_ window]; | |
| 42 } | 41 } |
| 43 | 42 |
| 44 scoped_nsobject<AboutWindowController> about_window_controller_; | 43 virtual void TearDown() { |
| 44 [about_window_controller_ close]; |
| 45 CocoaTest::TearDown(); |
| 46 } |
| 47 |
| 48 AboutWindowController* about_window_controller_; |
| 45 }; | 49 }; |
| 46 | 50 |
| 47 TEST_F(AboutWindowControllerTest, TestCopyright) { | 51 TEST_F(AboutWindowControllerTest, TestCopyright) { |
| 48 NSString* text = [[AboutWindowController legalTextBlock] string]; | 52 NSString* text = [[AboutWindowController legalTextBlock] string]; |
| 49 | 53 |
| 50 // Make sure we have the word "Copyright" in it, which is present in all | 54 // Make sure we have the word "Copyright" in it, which is present in all |
| 51 // locales. | 55 // locales. |
| 52 NSRange range = [text rangeOfString:@"Copyright"]; | 56 NSRange range = [text rangeOfString:@"Copyright"]; |
| 53 EXPECT_NE(NSNotFound, range.location); | 57 EXPECT_NE(NSNotFound, range.location); |
| 54 } | 58 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 75 TEST_F(AboutWindowControllerTest, TestButton) { | 79 TEST_F(AboutWindowControllerTest, TestButton) { |
| 76 NSButton* button = [about_window_controller_ updateButton]; | 80 NSButton* button = [about_window_controller_ updateButton]; |
| 77 ASSERT_TRUE(button); | 81 ASSERT_TRUE(button); |
| 78 | 82 |
| 79 // Not enabled until we know if updates are available. | 83 // Not enabled until we know if updates are available. |
| 80 ASSERT_FALSE([button isEnabled]); | 84 ASSERT_FALSE([button isEnabled]); |
| 81 PostAutoupdateStatusNotification(kAutoupdateAvailable, nil); | 85 PostAutoupdateStatusNotification(kAutoupdateAvailable, nil); |
| 82 ASSERT_TRUE([button isEnabled]); | 86 ASSERT_TRUE([button isEnabled]); |
| 83 | 87 |
| 84 // Make sure the button is hooked up | 88 // Make sure the button is hooked up |
| 85 ASSERT_EQ([button target], about_window_controller_.get()); | 89 ASSERT_EQ([button target], about_window_controller_); |
| 86 ASSERT_EQ([button action], @selector(updateNow:)); | 90 ASSERT_EQ([button action], @selector(updateNow:)); |
| 87 } | 91 } |
| 88 | 92 |
| 89 // Doesn't confirm correctness, but does confirm something happens. | 93 // Doesn't confirm correctness, but does confirm something happens. |
| 90 TEST_F(AboutWindowControllerTest, TestCallbacks) { | 94 TEST_F(AboutWindowControllerTest, TestCallbacks) { |
| 91 NSString *lastText = [[about_window_controller_ updateText] | 95 NSString *lastText = [[about_window_controller_ updateText] |
| 92 stringValue]; | 96 stringValue]; |
| 93 PostAutoupdateStatusNotification(kAutoupdateCurrent, @"foo"); | 97 PostAutoupdateStatusNotification(kAutoupdateCurrent, @"foo"); |
| 94 ASSERT_FALSE([lastText isEqual:[[about_window_controller_ updateText] | 98 ASSERT_FALSE([lastText isEqual:[[about_window_controller_ updateText] |
| 95 stringValue]]); | 99 stringValue]]); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 stringValue]]); | 135 stringValue]]); |
| 132 #endif | 136 #endif |
| 133 | 137 |
| 134 lastText = [[about_window_controller_ updateText] stringValue]; | 138 lastText = [[about_window_controller_ updateText] stringValue]; |
| 135 PostAutoupdateStatusNotification(kAutoupdateInstallFailed, nil); | 139 PostAutoupdateStatusNotification(kAutoupdateInstallFailed, nil); |
| 136 ASSERT_FALSE([lastText isEqual:[[about_window_controller_ | 140 ASSERT_FALSE([lastText isEqual:[[about_window_controller_ |
| 137 updateText] stringValue]]); | 141 updateText] stringValue]]); |
| 138 } | 142 } |
| 139 | 143 |
| 140 } // namespace | 144 } // namespace |
| OLD | NEW |