OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 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 "chrome/browser/ui/views/first_run_search_engine_view.h" |
| 6 |
| 7 #include "chrome/browser/search_engines/template_url.h" |
| 8 #include "chrome/browser/search_engines/template_url_service.h" |
| 9 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 10 #include "chrome/test/base/testing_profile.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 #include "ui/views/focus/accelerator_handler.h" |
| 13 #include "ui/views/test/views_test_base.h" |
| 14 #include "views/widget/widget.h" |
| 15 |
| 16 typedef views::ViewsTestBase FirstRunSearchEngineViewTest; |
| 17 |
| 18 TEST_F(FirstRunSearchEngineViewTest, ClosingSelectsFirstEngine) { |
| 19 // Create the first run search engine selector, and just close the window. |
| 20 // The first engine in the vector returned by GetTemplateURLs should be set as |
| 21 // the default engine. |
| 22 TestingProfile profile; |
| 23 profile.CreateTemplateURLService(); |
| 24 profile.BlockUntilTemplateURLServiceLoaded(); |
| 25 |
| 26 // Set a dummy provider as the default so we can verify something changed. |
| 27 TemplateURLService* service = |
| 28 TemplateURLServiceFactory::GetForProfile(&profile); |
| 29 ASSERT_TRUE(service != NULL); |
| 30 EXPECT_EQ(NULL, service->GetDefaultSearchProvider()); |
| 31 TemplateURL* d1 = new TemplateURL; |
| 32 TemplateURL* d2 = new TemplateURL; |
| 33 TemplateURL* d3 = new TemplateURL; |
| 34 service->Add(d1); |
| 35 service->Add(d2); |
| 36 service->Add(d3); |
| 37 service->SetDefaultSearchProvider(d3); |
| 38 |
| 39 FirstRunSearchEngineView* contents = |
| 40 new FirstRunSearchEngineView(&profile, false); |
| 41 contents->set_quit_on_closing(false); |
| 42 views::Widget* window = views::Widget::CreateWindow(contents); |
| 43 window->Show(); |
| 44 window->Close(); |
| 45 RunPendingMessages(); // Allows the window to be destroyed after Close(); |
| 46 |
| 47 TemplateURLService::TemplateURLVector template_urls = |
| 48 service->GetTemplateURLs(); |
| 49 ASSERT_TRUE(!template_urls.empty()); |
| 50 EXPECT_EQ(template_urls.front(), service->GetDefaultSearchProvider()); |
| 51 } |
OLD | NEW |