| 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 #include "base/scoped_nsobject.h" | 5 #include "base/scoped_nsobject.h" |
| 6 #include "chrome/browser/cocoa/browser_test_helper.h" | 6 #include "chrome/browser/cocoa/browser_test_helper.h" |
| 7 #import "chrome/browser/cocoa/custom_home_pages_model.h" | 7 #import "chrome/browser/cocoa/custom_home_pages_model.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 #include "testing/platform_test.h" |
| 9 | 10 |
| 10 // A helper for KVO and NSNotifications. Makes a note that it's been called | 11 // A helper for KVO and NSNotifications. Makes a note that it's been called |
| 11 // back. | 12 // back. |
| 12 @interface CustomHomePageHelper : NSObject { | 13 @interface CustomHomePageHelper : NSObject { |
| 13 @public | 14 @public |
| 14 BOOL sawNotification_; | 15 BOOL sawNotification_; |
| 15 } | 16 } |
| 16 @end | 17 @end |
| 17 | 18 |
| 18 @implementation CustomHomePageHelper | 19 @implementation CustomHomePageHelper |
| 19 - (void)observeValueForKeyPath:(NSString*)keyPath | 20 - (void)observeValueForKeyPath:(NSString*)keyPath |
| 20 ofObject:(id)object | 21 ofObject:(id)object |
| 21 change:(NSDictionary*)change | 22 change:(NSDictionary*)change |
| 22 context:(void*)context { | 23 context:(void*)context { |
| 23 sawNotification_ = YES; | 24 sawNotification_ = YES; |
| 24 } | 25 } |
| 25 | 26 |
| 26 - (void)entryChanged:(NSNotification*)notify { | 27 - (void)entryChanged:(NSNotification*)notify { |
| 27 sawNotification_ = YES; | 28 sawNotification_ = YES; |
| 28 } | 29 } |
| 29 @end | 30 @end |
| 30 | 31 |
| 31 class CustomHomePagesModelTest : public testing::Test { | 32 class CustomHomePagesModelTest : public PlatformTest { |
| 32 public: | 33 public: |
| 33 CustomHomePagesModelTest() { | 34 CustomHomePagesModelTest() { |
| 34 model_.reset([[CustomHomePagesModel alloc] | 35 model_.reset([[CustomHomePagesModel alloc] |
| 35 initWithProfile:helper_.profile()]); | 36 initWithProfile:helper_.profile()]); |
| 36 } | 37 } |
| 37 ~CustomHomePagesModelTest() { } | 38 ~CustomHomePagesModelTest() { } |
| 38 | 39 |
| 39 BrowserTestHelper helper_; | 40 BrowserTestHelper helper_; |
| 40 scoped_nsobject<CustomHomePagesModel> model_; | 41 scoped_nsobject<CustomHomePagesModel> model_; |
| 41 }; | 42 }; |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 object:nil]; | 143 object:nil]; |
| 143 | 144 |
| 144 std::vector<GURL> urls; | 145 std::vector<GURL> urls; |
| 145 urls.push_back(GURL("http://www.google.com")); | 146 urls.push_back(GURL("http://www.google.com")); |
| 146 [model_ setURLs:urls]; | 147 [model_ setURLs:urls]; |
| 147 NSObject* entry = [model_ objectInCustomHomePagesAtIndex:0]; | 148 NSObject* entry = [model_ objectInCustomHomePagesAtIndex:0]; |
| 148 [entry setURL:@"http://www.foo.bar"]; | 149 [entry setURL:@"http://www.foo.bar"]; |
| 149 EXPECT_TRUE(kvo_helper.get()->sawNotification_); | 150 EXPECT_TRUE(kvo_helper.get()->sawNotification_); |
| 150 [[NSNotificationCenter defaultCenter] removeObserver:kvo_helper]; | 151 [[NSNotificationCenter defaultCenter] removeObserver:kvo_helper]; |
| 151 } | 152 } |
| OLD | NEW |