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

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

Issue 99238: Add notification (and unit test) for closing prefs window so it can be cleane... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 8 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/preferences_window_controller.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/cocoa/preferences_window_controller_unittest.mm
===================================================================
--- chrome/browser/cocoa/preferences_window_controller_unittest.mm (revision 14958)
+++ chrome/browser/cocoa/preferences_window_controller_unittest.mm (working copy)
@@ -11,6 +11,21 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/platform_test.h"
+// Helper Objective-C object that sets a BOOL when we get a particular
+// callback from the prefs window.
+@interface PrefsClosedObserver : NSObject {
+ @public
+ BOOL gotNotification_;
+}
+- (void)prefsWindowClosed:(NSNotification*)notify;
+@end
+
+@implementation PrefsClosedObserver
+- (void)prefsWindowClosed:(NSNotification*)notify {
+ gotNotification_ = YES;
+}
+@end
+
namespace {
class PrefsControllerTest : public PlatformTest {
@@ -27,10 +42,22 @@
scoped_nsobject<PreferencesWindowController> pref_controller_;
};
-// Test showing the preferences window and making sure it's visible
-TEST_F(PrefsControllerTest, Show) {
+// Test showing the preferences window and making sure it's visible, then
+// making sure we get the notification when it's closed.
+TEST_F(PrefsControllerTest, ShowAndClose) {
[pref_controller_ showPreferences:nil];
EXPECT_TRUE([[pref_controller_ window] isVisible]);
+
+ scoped_nsobject<PrefsClosedObserver> observer(
+ [[PrefsClosedObserver alloc] init]);
+ [[NSNotificationCenter defaultCenter]
+ addObserver:observer.get()
+ selector:@selector(prefsWindowClosed:)
+ name:kUserDoneEditingPrefsNotification
+ object:pref_controller_.get()];
+ [[pref_controller_ window] performClose:observer];
+ EXPECT_TRUE(observer.get()->gotNotification_);
+ [[NSNotificationCenter defaultCenter] removeObserver:observer.get()];
}
} // namespace
« no previous file with comments | « chrome/browser/cocoa/preferences_window_controller.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698