diff options
author | mrossetti@chromium.org <mrossetti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-14 01:56:18 +0000 |
---|---|---|
committer | mrossetti@chromium.org <mrossetti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-14 01:56:18 +0000 |
commit | 377c358090c1e25fe160f9f3c7d3dd34f397c717 (patch) | |
tree | c407db030e52586ff3ac5f5f3c2f539be34fb463 | |
parent | ac3c102d462701dd6a7ef0046bddb54c0a9fe706 (diff) | |
download | chromium_src-377c358090c1e25fe160f9f3c7d3dd34f397c717.zip chromium_src-377c358090c1e25fe160f9f3c7d3dd34f397c717.tar.gz chromium_src-377c358090c1e25fe160f9f3c7d3dd34f397c717.tar.bz2 |
Revert 142048 - Move thread checking from autofill_country.cc to browser_process_impl.cc
DCHECK(CalledOnValidThread()) is better than BrowserThread::CurrentlyOn(...)
because it automatically supports unit test without requiring setting up
specific threads.
BUG=132643
TEST=Run Autofill tests in debug build
Review URL: https://chromiumcodereview.appspot.com/10545169
TBR=wangxianzhu@chromium.org
Review URL: https://chromiumcodereview.appspot.com/10533143
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@142066 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/autofill/address_unittest.cc | 23 | ||||
-rw-r--r-- | chrome/browser/autofill/autofill_country.cc | 4 | ||||
-rw-r--r-- | chrome/browser/browser_process_impl.cc | 2 |
3 files changed, 21 insertions, 8 deletions
diff --git a/chrome/browser/autofill/address_unittest.cc b/chrome/browser/autofill/address_unittest.cc index 6a8330b..64c7d5f 100644 --- a/chrome/browser/autofill/address_unittest.cc +++ b/chrome/browser/autofill/address_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -14,8 +14,21 @@ using content::BrowserThread; +class AddressTest : public testing::Test { + public: + // In order to access the application locale -- which the tested functions do + // internally -- this test must run on the UI thread. + AddressTest() : ui_thread_(BrowserThread::UI, &message_loop_) {} + + private: + MessageLoopForUI message_loop_; + content::TestBrowserThread ui_thread_; + + DISALLOW_COPY_AND_ASSIGN(AddressTest); +}; + // Test that the getters and setters for country code are working. -TEST(AddressTest, CountryCode) { +TEST_F(AddressTest, CountryCode) { Address address; EXPECT_EQ(std::string(), address.country_code()); @@ -27,7 +40,7 @@ TEST(AddressTest, CountryCode) { } // Test that country codes are properly decoded as country names. -TEST(AddressTest, GetCountry) { +TEST_F(AddressTest, GetCountry) { Address address; EXPECT_EQ(std::string(), address.country_code()); @@ -45,7 +58,7 @@ TEST(AddressTest, GetCountry) { } // Test that we properly detect country codes appropriate for each country. -TEST(AddressTest, SetCountry) { +TEST_F(AddressTest, SetCountry) { Address address; EXPECT_EQ(std::string(), address.country_code()); @@ -81,7 +94,7 @@ TEST(AddressTest, SetCountry) { } // Test that we properly match typed values to stored country data. -TEST(AddressTest, IsCountry) { +TEST_F(AddressTest, IsCountry) { Address address; address.set_country_code("US"); diff --git a/chrome/browser/autofill/autofill_country.cc b/chrome/browser/autofill/autofill_country.cc index 8eb5b52..2dea6af 100644 --- a/chrome/browser/autofill/autofill_country.cc +++ b/chrome/browser/autofill/autofill_country.cc @@ -422,8 +422,10 @@ CountryNames* CountryNames::GetInstance() { } const std::string CountryNames::ApplicationLocale() { - if (application_locale_.empty()) + if (application_locale_.empty()) { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); application_locale_ = g_browser_process->GetApplicationLocale(); + } return application_locale_; } diff --git a/chrome/browser/browser_process_impl.cc b/chrome/browser/browser_process_impl.cc index 05b1ac4..f3e5f0b 100644 --- a/chrome/browser/browser_process_impl.cc +++ b/chrome/browser/browser_process_impl.cc @@ -531,13 +531,11 @@ IntranetRedirectDetector* BrowserProcessImpl::intranet_redirect_detector() { } const std::string& BrowserProcessImpl::GetApplicationLocale() { - DCHECK(CalledOnValidThread()); DCHECK(!locale_.empty()); return locale_; } void BrowserProcessImpl::SetApplicationLocale(const std::string& locale) { - DCHECK(CalledOnValidThread()); locale_ = locale; extension_l10n_util::SetProcessLocale(locale); } |