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/search_engine_list_model.h" | 7 #import "chrome/browser/cocoa/search_engine_list_model.h" |
8 #include "chrome/browser/profile.h" | 8 #include "chrome/browser/profile.h" |
9 #include "chrome/browser/search_engines/template_url.h" | 9 #include "chrome/browser/search_engines/template_url.h" |
10 #include "chrome/browser/search_engines/template_url_model.h" | 10 #include "chrome/browser/search_engines/template_url_model.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 #include "testing/platform_test.h" |
12 | 13 |
13 // A helper for NSNotifications. Makes a note that it's been called back. | 14 // A helper for NSNotifications. Makes a note that it's been called back. |
14 @interface SearchEngineListHelper : NSObject { | 15 @interface SearchEngineListHelper : NSObject { |
15 @public | 16 @public |
16 BOOL sawNotification_; | 17 BOOL sawNotification_; |
17 } | 18 } |
18 @end | 19 @end |
19 | 20 |
20 @implementation SearchEngineListHelper | 21 @implementation SearchEngineListHelper |
21 - (void)entryChanged:(NSNotification*)notify { | 22 - (void)entryChanged:(NSNotification*)notify { |
22 sawNotification_ = YES; | 23 sawNotification_ = YES; |
23 } | 24 } |
24 @end | 25 @end |
25 | 26 |
26 class SearchEngineListModelTest : public testing::Test { | 27 class SearchEngineListModelTest : public PlatformTest { |
27 public: | 28 public: |
28 SearchEngineListModelTest() { | 29 SearchEngineListModelTest() { |
29 // Build a fake set of template urls. | 30 // Build a fake set of template urls. |
30 template_model_.reset(new TemplateURLModel(helper_.profile())); | 31 template_model_.reset(new TemplateURLModel(helper_.profile())); |
31 TemplateURL* t_url = new TemplateURL(); | 32 TemplateURL* t_url = new TemplateURL(); |
32 t_url->SetURL(L"http://www.google.com/foo/bar", 0, 0); | 33 t_url->SetURL(L"http://www.google.com/foo/bar", 0, 0); |
33 t_url->set_keyword(L"keyword"); | 34 t_url->set_keyword(L"keyword"); |
34 t_url->set_short_name(L"google"); | 35 t_url->set_short_name(L"google"); |
35 t_url->set_show_in_default_list(true); | 36 t_url->set_show_in_default_list(true); |
36 template_model_->Add(t_url); | 37 template_model_->Add(t_url); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 // Add one more item to force a notification. | 87 // Add one more item to force a notification. |
87 TemplateURL* t_url = new TemplateURL(); | 88 TemplateURL* t_url = new TemplateURL(); |
88 t_url->SetURL(L"http://www.google3.com/foo/bar", 0, 0); | 89 t_url->SetURL(L"http://www.google3.com/foo/bar", 0, 0); |
89 t_url->set_keyword(L"keyword3"); | 90 t_url->set_keyword(L"keyword3"); |
90 t_url->set_short_name(L"google3"); | 91 t_url->set_short_name(L"google3"); |
91 t_url->set_show_in_default_list(true); | 92 t_url->set_show_in_default_list(true); |
92 template_model_->Add(t_url); | 93 template_model_->Add(t_url); |
93 | 94 |
94 EXPECT_TRUE(notification_helper_.get()->sawNotification_); | 95 EXPECT_TRUE(notification_helper_.get()->sawNotification_); |
95 } | 96 } |
OLD | NEW |