diff options
author | mark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-26 19:58:13 +0000 |
---|---|---|
committer | mark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-26 19:58:13 +0000 |
commit | 49aeee5080135d65173fb06f117cbb19f87ae867 (patch) | |
tree | 13ea17786c1cd4c59c833906f3d26ef92a50b091 /chrome/browser/cocoa/about_window_controller_unittest.mm | |
parent | 8dd8ea73b9fc2571777d841a85f0b27f82530455 (diff) | |
download | chromium_src-49aeee5080135d65173fb06f117cbb19f87ae867.zip chromium_src-49aeee5080135d65173fb06f117cbb19f87ae867.tar.gz chromium_src-49aeee5080135d65173fb06f117cbb19f87ae867.tar.bz2 |
About box auto-update improvements.
The About box now knows how to check to see if updates have been installed
in the background without anyone having to click the Update button in the box.
The About box no longer gets stuck in the "installed" state. Even if an
update has been installed, the About box will still check for new updates when
reopened.
BUG=13165, 20488
TEST=Play with the about box and auto-update a whole lot
Review URL: http://codereview.chromium.org/338012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30078 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa/about_window_controller_unittest.mm')
-rw-r--r-- | chrome/browser/cocoa/about_window_controller_unittest.mm | 74 |
1 files changed, 64 insertions, 10 deletions
diff --git a/chrome/browser/cocoa/about_window_controller_unittest.mm b/chrome/browser/cocoa/about_window_controller_unittest.mm index 3117b08..c7b65fe 100644 --- a/chrome/browser/cocoa/about_window_controller_unittest.mm +++ b/chrome/browser/cocoa/about_window_controller_unittest.mm @@ -5,6 +5,7 @@ #import <Cocoa/Cocoa.h> #import "base/scoped_nsobject.h" +#import "chrome/app/keystone_glue.h" #import "chrome/browser/cocoa/about_window_controller.h" #include "chrome/browser/cocoa/browser_test_helper.h" #include "chrome/browser/cocoa/cocoa_test_helper.h" @@ -13,6 +14,23 @@ namespace { +void PostAutoupdateStatusNotification(AutoupdateStatus status, + NSString* version) { + NSNumber* statusNumber = [NSNumber numberWithInt:status]; + NSMutableDictionary* dictionary = + [NSMutableDictionary dictionaryWithObjects:&statusNumber + forKeys:&kAutoupdateStatusStatus + count:1]; + if (version) { + [dictionary setObject:version forKey:kAutoupdateStatusVersion]; + } + + NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; + [center postNotificationName:kAutoupdateStatusNotification + object:nil + userInfo:dictionary]; +} + class AboutWindowControllerTest : public PlatformTest { public: virtual void SetUp() { @@ -27,7 +45,7 @@ class AboutWindowControllerTest : public PlatformTest { }; TEST_F(AboutWindowControllerTest, TestCopyright) { - NSString* text = [BuildAboutWindowLegalTextBlock() string]; + NSString* text = [[AboutWindowController legalTextBlock] string]; // Make sure we have the word "Copyright" in it, which is present in all // locales. @@ -36,7 +54,7 @@ TEST_F(AboutWindowControllerTest, TestCopyright) { } TEST_F(AboutWindowControllerTest, RemovesLinkAnchors) { - NSString* text = [BuildAboutWindowLegalTextBlock() string]; + NSString* text = [[AboutWindowController legalTextBlock] string]; // Make sure that we removed the "BEGIN_LINK" and "END_LINK" anchors. NSRange range = [text rangeOfString:@"BEGIN_LINK"]; @@ -47,7 +65,7 @@ TEST_F(AboutWindowControllerTest, RemovesLinkAnchors) { } TEST_F(AboutWindowControllerTest, AwakeNibSetsString) { - NSAttributedString* legal_text = BuildAboutWindowLegalTextBlock(); + NSAttributedString* legal_text = [AboutWindowController legalTextBlock]; NSAttributedString* text_storage = [[about_window_controller_ legalText] textStorage]; @@ -60,7 +78,7 @@ TEST_F(AboutWindowControllerTest, TestButton) { // Not enabled until we know if updates are available. ASSERT_FALSE([button isEnabled]); - [about_window_controller_ upToDateCheckCompleted:YES latestVersion:nil]; + PostAutoupdateStatusNotification(kAutoupdateAvailable, nil); ASSERT_TRUE([button isEnabled]); // Make sure the button is hooked up @@ -75,16 +93,52 @@ TEST_F(AboutWindowControllerTest, TestButton) { // Doesn't confirm correctness, but does confirm something happens. TEST_F(AboutWindowControllerTest, TestCallbacks) { NSString *lastText = [[about_window_controller_ updateText] - stringValue]; - [about_window_controller_ upToDateCheckCompleted:NO latestVersion:@"foo"]; + stringValue]; + PostAutoupdateStatusNotification(kAutoupdateCurrent, @"foo"); + ASSERT_FALSE([lastText isEqual:[[about_window_controller_ updateText] + stringValue]]); + + lastText = [[about_window_controller_ updateText] stringValue]; + PostAutoupdateStatusNotification(kAutoupdateCurrent, @"foo"); + ASSERT_TRUE([lastText isEqual:[[about_window_controller_ updateText] + stringValue]]); + + lastText = [[about_window_controller_ updateText] stringValue]; + PostAutoupdateStatusNotification(kAutoupdateCurrent, @"bar"); + ASSERT_FALSE([lastText isEqual:[[about_window_controller_ updateText] + stringValue]]); + + lastText = [[about_window_controller_ updateText] stringValue]; + PostAutoupdateStatusNotification(kAutoupdateAvailable, nil); ASSERT_FALSE([lastText isEqual:[[about_window_controller_ updateText] - stringValue]]); + stringValue]]); lastText = [[about_window_controller_ updateText] stringValue]; - [about_window_controller_ updateCompleted:NO installs:0]; + PostAutoupdateStatusNotification(kAutoupdateCheckFailed, nil); + ASSERT_FALSE([lastText isEqual:[[about_window_controller_ updateText] + stringValue]]); + +#if 0 + // TODO(mark): The kAutoupdateInstalled portion of the test is disabled + // because it leaks restart dialogs. If the About box is revised to use + // a button within the box to advise a restart instead of popping dialogs, + // these tests should be enabled. + + lastText = [[about_window_controller_ updateText] stringValue]; + PostAutoupdateStatusNotification(kAutoupdateInstalled, @"ver"); + ASSERT_FALSE([lastText isEqual:[[about_window_controller_ updateText] + stringValue]]); + + lastText = [[about_window_controller_ updateText] stringValue]; + PostAutoupdateStatusNotification(kAutoupdateInstalled, nil); + ASSERT_FALSE([lastText isEqual:[[about_window_controller_ updateText] + stringValue]]); +#endif + + lastText = [[about_window_controller_ updateText] stringValue]; + PostAutoupdateStatusNotification(kAutoupdateInstallFailed, nil); ASSERT_FALSE([lastText isEqual:[[about_window_controller_ - updateText] stringValue]]); + updateText] stringValue]]); } } // namespace - |