| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "base/scoped_nsobject.h" |
| 6 #include "chrome/browser/browser.h" |
| 7 #include "chrome/browser/cocoa/browser_test_helper.h" |
| 8 #include "chrome/browser/cocoa/cocoa_test_helper.h" |
| 9 #import "chrome/browser/cocoa/keyword_editor_cocoa_controller.h" |
| 10 #include "chrome/test/testing_profile.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 #include "testing/platform_test.h" |
| 13 |
| 14 @interface FakeKeywordEditorController : KeywordEditorCocoaController { |
| 15 @public |
| 16 BOOL changed_; |
| 17 } |
| 18 - (KeywordEditorModelObserver*)observer; |
| 19 @end |
| 20 |
| 21 @implementation FakeKeywordEditorController |
| 22 - (void)modelChanged { |
| 23 changed_ = YES; |
| 24 } |
| 25 - (KeywordEditorModelObserver*)observer { |
| 26 return observer_.get(); |
| 27 } |
| 28 @end |
| 29 |
| 30 // TODO(rsesek): Figure out a good way to test this class (crbug.com/21640). |
| 31 |
| 32 class KeywordEditorCocoaControllerTest : public PlatformTest { |
| 33 public: |
| 34 void SetUp() { |
| 35 TestingProfile* profile = |
| 36 static_cast<TestingProfile*>(browser_helper_.profile()); |
| 37 profile->CreateTemplateURLModel(); |
| 38 controller_.reset( |
| 39 [[FakeKeywordEditorController alloc] initWithProfile:profile]); |
| 40 } |
| 41 |
| 42 CocoaTestHelper cocoa_helper_; |
| 43 BrowserTestHelper browser_helper_; |
| 44 scoped_nsobject<FakeKeywordEditorController> controller_; |
| 45 }; |
| 46 |
| 47 TEST_F(KeywordEditorCocoaControllerTest, TestModelChanged) { |
| 48 EXPECT_FALSE(controller_.get()->changed_); |
| 49 KeywordEditorModelObserver* observer = [controller_ observer]; |
| 50 observer->OnTemplateURLModelChanged(); |
| 51 EXPECT_TRUE(controller_.get()->changed_); |
| 52 } |
| OLD | NEW |