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

Side by Side Diff: chrome/browser/ui/search/local_ntp_browsertest.cc

Issue 2835233002: Fix integration tests in src/chrome and src/extensions so that we can turn on IO thread checks wi... (Closed)
Patch Set: ready for review Created 3 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/command_line.h" 5 #include "base/command_line.h"
6 #include "base/strings/utf_string_conversions.h" 6 #include "base/strings/utf_string_conversions.h"
7 #include "base/threading/thread_restrictions.h"
7 #include "chrome/browser/browser_process.h" 8 #include "chrome/browser/browser_process.h"
8 #include "chrome/browser/chrome_notification_types.h" 9 #include "chrome/browser/chrome_notification_types.h"
9 #include "chrome/browser/search/search.h" 10 #include "chrome/browser/search/search.h"
10 #include "chrome/browser/search_engines/template_url_service_factory.h" 11 #include "chrome/browser/search_engines/template_url_service_factory.h"
11 #include "chrome/browser/ui/browser_commands.h" 12 #include "chrome/browser/ui/browser_commands.h"
12 #include "chrome/browser/ui/search/instant_test_utils.h" 13 #include "chrome/browser/ui/search/instant_test_utils.h"
13 #include "chrome/browser/ui/tabs/tab_strip_model.h" 14 #include "chrome/browser/ui/tabs/tab_strip_model.h"
14 #include "chrome/common/pref_names.h" 15 #include "chrome/common/pref_names.h"
15 #include "chrome/common/url_constants.h" 16 #include "chrome/common/url_constants.h"
16 #include "chrome/test/base/in_process_browser_test.h" 17 #include "chrome/test/base/in_process_browser_test.h"
(...skipping 16 matching lines...) Expand all
33 #include "net/test/embedded_test_server/embedded_test_server.h" 34 #include "net/test/embedded_test_server/embedded_test_server.h"
34 #include "ui/base/resource/resource_bundle.h" 35 #include "ui/base/resource/resource_bundle.h"
35 #include "ui/gfx/geometry/point.h" 36 #include "ui/gfx/geometry/point.h"
36 #include "ui/gfx/geometry/rect.h" 37 #include "ui/gfx/geometry/rect.h"
37 #include "ui/gfx/geometry/vector2d.h" 38 #include "ui/gfx/geometry/vector2d.h"
38 39
39 namespace { 40 namespace {
40 41
41 // Switches the browser language to French, and returns true iff successful. 42 // Switches the browser language to French, and returns true iff successful.
42 bool SwitchToFrench() { 43 bool SwitchToFrench() {
44 base::ThreadRestrictions::ScopedAllowIO allow_io;
43 // Make sure the default language is not French. 45 // Make sure the default language is not French.
44 std::string default_locale = g_browser_process->GetApplicationLocale(); 46 std::string default_locale = g_browser_process->GetApplicationLocale();
45 EXPECT_NE("fr", default_locale); 47 EXPECT_NE("fr", default_locale);
46 48
47 // Switch browser language to French. 49 // Switch browser language to French.
48 std::string loaded_locale = 50 std::string loaded_locale =
49 ui::ResourceBundle::GetSharedInstance().ReloadLocaleResources("fr"); 51 ui::ResourceBundle::GetSharedInstance().ReloadLocaleResources("fr");
50 52
51 return loaded_locale == "fr"; 53 return loaded_locale == "fr";
52 } 54 }
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 EXPECT_EQ(0, failed_imgs); 300 EXPECT_EQ(0, failed_imgs);
299 } 301 }
300 302
301 IN_PROC_BROWSER_TEST_F(LocalNTPTest, 303 IN_PROC_BROWSER_TEST_F(LocalNTPTest,
302 NTPRespectsBrowserLanguageSetting) { 304 NTPRespectsBrowserLanguageSetting) {
303 // Make sure the default language is not French. 305 // Make sure the default language is not French.
304 std::string default_locale = g_browser_process->GetApplicationLocale(); 306 std::string default_locale = g_browser_process->GetApplicationLocale();
305 EXPECT_NE("fr", default_locale); 307 EXPECT_NE("fr", default_locale);
306 308
307 // Switch browser language to French. 309 // Switch browser language to French.
310 base::ThreadRestrictions::ScopedAllowIO allow_io;
308 std::string loaded_locale = 311 std::string loaded_locale =
309 ui::ResourceBundle::GetSharedInstance().ReloadLocaleResources("fr"); 312 ui::ResourceBundle::GetSharedInstance().ReloadLocaleResources("fr");
310 313
311 // If the platform cannot load the French locale (GetApplicationLocale() is 314 // If the platform cannot load the French locale (GetApplicationLocale() is
312 // platform specific, and has been observed to fail on a small number of 315 // platform specific, and has been observed to fail on a small number of
313 // platforms), abort the test. 316 // platforms), abort the test.
314 if (!SwitchToFrench()) { 317 if (!SwitchToFrench()) {
315 LOG(ERROR) << "Failed switching to French language, aborting test."; 318 LOG(ERROR) << "Failed switching to French language, aborting test.";
316 return; 319 return;
317 } 320 }
(...skipping 24 matching lines...) Expand all
342 class LocalNTPSmokeTest : public InProcessBrowserTest { 345 class LocalNTPSmokeTest : public InProcessBrowserTest {
343 public: 346 public:
344 LocalNTPSmokeTest() {} 347 LocalNTPSmokeTest() {}
345 348
346 protected: 349 protected:
347 void SetUpCommandLine(base::CommandLine* cmdline) override { 350 void SetUpCommandLine(base::CommandLine* cmdline) override {
348 cmdline->AppendSwitchASCII(switches::kEnableFeatures, "UseGoogleLocalNtp"); 351 cmdline->AppendSwitchASCII(switches::kEnableFeatures, "UseGoogleLocalNtp");
349 } 352 }
350 353
351 void SetUserSelectedDefaultSearchProvider(const std::string& base_url) { 354 void SetUserSelectedDefaultSearchProvider(const std::string& base_url) {
355 base::ThreadRestrictions::ScopedAllowIO allow_io;
352 TemplateURLData data; 356 TemplateURLData data;
353 data.SetShortName(base::UTF8ToUTF16(base_url)); 357 data.SetShortName(base::UTF8ToUTF16(base_url));
354 data.SetKeyword(base::UTF8ToUTF16(base_url)); 358 data.SetKeyword(base::UTF8ToUTF16(base_url));
355 data.SetURL(base_url + "url?bar={searchTerms}"); 359 data.SetURL(base_url + "url?bar={searchTerms}");
356 360
357 TemplateURLService* template_url_service = 361 TemplateURLService* template_url_service =
358 TemplateURLServiceFactory::GetForProfile(browser()->profile()); 362 TemplateURLServiceFactory::GetForProfile(browser()->profile());
359 TemplateURL* template_url = 363 TemplateURL* template_url =
360 template_url_service->Add(base::MakeUnique<TemplateURL>(data)); 364 template_url_service->Add(base::MakeUnique<TemplateURL>(data));
361 template_url_service->SetUserSelectedDefaultSearchProvider(template_url); 365 template_url_service->SetUserSelectedDefaultSearchProvider(template_url);
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL)); 439 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL));
436 ASSERT_TRUE(search::IsInstantNTP(active_tab)); 440 ASSERT_TRUE(search::IsInstantNTP(active_tab));
437 ASSERT_EQ(GURL(chrome::kChromeSearchLocalNtpUrl), 441 ASSERT_EQ(GURL(chrome::kChromeSearchLocalNtpUrl),
438 active_tab->GetController().GetVisibleEntry()->GetURL()); 442 active_tab->GetController().GetVisibleEntry()->GetURL());
439 // Make sure it's actually in French. 443 // Make sure it's actually in French.
440 ASSERT_EQ(base::ASCIIToUTF16("Nouvel onglet"), active_tab->GetTitle()); 444 ASSERT_EQ(base::ASCIIToUTF16("Nouvel onglet"), active_tab->GetTitle());
441 445
442 // We shouldn't have gotten any console error messages. 446 // We shouldn't have gotten any console error messages.
443 EXPECT_TRUE(console_observer.message().empty()) << console_observer.message(); 447 EXPECT_TRUE(console_observer.message().empty()) << console_observer.message();
444 } 448 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698