Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(974)

Unified Diff: chrome/browser/cocoa/about_window_controller_unittest.mm

Issue 338012: About box auto-update improvements (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/cocoa/about_window_controller.mm ('k') | chrome/browser/cocoa/restart_browser.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/cocoa/about_window_controller_unittest.mm
===================================================================
--- chrome/browser/cocoa/about_window_controller_unittest.mm (revision 30049)
+++ chrome/browser/cocoa/about_window_controller_unittest.mm (working copy)
@@ -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 @@
};
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, 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, AwakeNibSetsString) {
- NSAttributedString* legal_text = BuildAboutWindowLegalTextBlock();
+ NSAttributedString* legal_text = [AboutWindowController legalTextBlock];
NSAttributedString* text_storage =
[[about_window_controller_ legalText] textStorage];
@@ -60,7 +78,7 @@
// 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 @@
// 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]]);
+ stringValue]]);
lastText = [[about_window_controller_ updateText] stringValue];
- [about_window_controller_ updateCompleted:NO installs:0];
+ 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]]);
+
+ lastText = [[about_window_controller_ updateText] stringValue];
+ 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
-
« no previous file with comments | « chrome/browser/cocoa/about_window_controller.mm ('k') | chrome/browser/cocoa/restart_browser.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698