Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1151)

Unified Diff: chrome/browser/ui/views/first_run_search_engine_view_unittest.cc

Issue 9285002: Remove the first-run search engine dialog/ballot. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync and merge. Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/views/first_run_search_engine_view.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/first_run_search_engine_view_unittest.cc
diff --git a/chrome/browser/ui/views/first_run_search_engine_view_unittest.cc b/chrome/browser/ui/views/first_run_search_engine_view_unittest.cc
deleted file mode 100644
index 0532c49ec7728678cccceab6ba31ef7705b810c4..0000000000000000000000000000000000000000
--- a/chrome/browser/ui/views/first_run_search_engine_view_unittest.cc
+++ /dev/null
@@ -1,113 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/ui/views/first_run_search_engine_view.h"
-
-#include "base/threading/thread.h"
-#include "chrome/browser/search_engines/template_url.h"
-#include "chrome/browser/search_engines/template_url_service.h"
-#include "chrome/browser/search_engines/template_url_service_factory.h"
-#include "chrome/common/chrome_notification_types.h"
-#include "chrome/test/base/testing_profile.h"
-#include "chrome/test/base/ui_test_utils.h"
-#include "content/public/browser/notification_service.h"
-#include "content/test/test_browser_thread.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "ui/views/focus/accelerator_handler.h"
-#include "ui/views/test/views_test_base.h"
-#include "ui/views/widget/widget.h"
-
-typedef views::ViewsTestBase FirstRunSearchEngineViewTest;
-
-TEST_F(FirstRunSearchEngineViewTest, ClosingSelectsFirstEngine) {
- // Create the first run search engine selector, and just close the window.
- // The first engine in the vector returned by GetTemplateURLs should be set as
- // the default engine.
- TestingProfile profile;
- profile.CreateTemplateURLService();
- profile.BlockUntilTemplateURLServiceLoaded();
-
- // Set a dummy provider as the default so we can verify something changed.
- TemplateURLService* service =
- TemplateURLServiceFactory::GetForProfile(&profile);
- ASSERT_TRUE(service != NULL);
- EXPECT_EQ(NULL, service->GetDefaultSearchProvider());
- TemplateURL* d1 = new TemplateURL;
- TemplateURL* d2 = new TemplateURL;
- TemplateURL* d3 = new TemplateURL;
- service->Add(d1);
- service->Add(d2);
- service->Add(d3);
- service->SetDefaultSearchProvider(d3);
-
- FirstRunSearchEngineView* contents =
- new FirstRunSearchEngineView(&profile, false);
- contents->set_quit_on_closing(false);
- views::Widget* window = views::Widget::CreateWindow(contents);
- window->Show();
- window->Close();
- RunPendingMessages(); // Allows the window to be destroyed after Close();
-
- TemplateURLService::TemplateURLVector template_urls =
- service->GetTemplateURLs();
- ASSERT_TRUE(!template_urls.empty());
- EXPECT_EQ(template_urls.front(), service->GetDefaultSearchProvider());
-}
-
-// http://code.google.com/p/chromium/issues/detail?id=111062
-TEST_F(FirstRunSearchEngineViewTest,
- FLAKY_ClosingBeforeServiceLoadedAbortsClose) {
- // This ensures the current thread is named the UI thread, so code that checks
- // that this is the UI thread doesn't assert.
- base::Thread db_thread("tempdbthread");
- db_thread.Start();
- content::TestBrowserThread ui_thread(content::BrowserThread::UI,
- message_loop());
- content::TestBrowserThread db_test_thread(content::BrowserThread::DB,
- db_thread.message_loop());
-
- TestingProfile profile;
- // We need to initialize the web database before accessing the template url
- // service otherwise the template url service will init itself synchronously
- // and appear to be loaded.
- profile.CreateWebDataService(false);
- profile.CreateTemplateURLService();
-
- // Instead of giving the template url service a chance to load, try and close
- // the window immediately.
- FirstRunSearchEngineView* contents =
- new FirstRunSearchEngineView(&profile, false);
- contents->set_quit_on_closing(false);
- views::Widget* window = views::Widget::CreateWindow(contents);
- window->Show();
- EXPECT_TRUE(window->IsVisible());
- window->Close();
- // The window wouldn't actually be closed until a return to the message loop,
- // which we don't want to spin here because the window shouldn't have closed
- // in the correct case. The window is however actually hidden immediately when
- // the window is allowed to close, so we can test for visibility to make sure
- // it hasn't.
- EXPECT_TRUE(window->IsVisible());
-
- // Now let the template url service a chance to load.
- ui_test_utils::WindowedNotificationObserver service_load_observer(
- chrome::NOTIFICATION_TEMPLATE_URL_SERVICE_LOADED,
- content::NotificationService::AllSources());
- service_load_observer.Wait();
-
- // .. and try and close the window. It should be allowed to now.
- window->Close();
- EXPECT_FALSE(window->IsVisible());
-
- // Allow the window to actually close.
- RunPendingMessages();
-
- // Verify goodness. Because we actually went to the trouble of starting the
- // WebDB, we will have real data in the model, so we can verify a choice was
- // made without having to seed the model with dummy data.
- TemplateURLService* service =
- TemplateURLServiceFactory::GetForProfile(&profile);
- ASSERT_TRUE(service != NULL);
- EXPECT_TRUE(service->GetDefaultSearchProvider() != NULL);
-}
« no previous file with comments | « chrome/browser/ui/views/first_run_search_engine_view.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698