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