diff options
author | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-15 07:35:37 +0000 |
---|---|---|
committer | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-15 07:35:37 +0000 |
commit | 79457797443d45463b92abcda0124706bdf1aff5 (patch) | |
tree | 83c22707ecc9649686be8d5bb5bd74913c4520d8 /chrome/browser/autocomplete/autocomplete_unittest.cc | |
parent | af980796c6c9df7bd06210397ffa5dad155ebf66 (diff) | |
download | chromium_src-79457797443d45463b92abcda0124706bdf1aff5.zip chromium_src-79457797443d45463b92abcda0124706bdf1aff5.tar.gz chromium_src-79457797443d45463b92abcda0124706bdf1aff5.tar.bz2 |
GTTF: Use a fresh TestingBrowserProcess for each test, part #1
This is going to be done in multiple steps,
because lots of tests depend on global TestingBrowserProcess.
However, the current solution is very error-prone,
and may lead to state being carried from one test
to another (via NotificationService), resulting in crashes.
In theory the ScopedTestingBrowserProcess could be made
empty for now, but re-initializing g_browser_process inside it
has two benefits:
1) It verifies that changing g_browser_process actually works.
2) It protects at least a subset of tests from carrying state.
BUG=61062
TEST=unit_tests, possibly more
Review URL: http://codereview.chromium.org/6478005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@74926 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autocomplete/autocomplete_unittest.cc')
-rw-r--r-- | chrome/browser/autocomplete/autocomplete_unittest.cc | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_unittest.cc b/chrome/browser/autocomplete/autocomplete_unittest.cc index 93ce9da..cb8e719 100644 --- a/chrome/browser/autocomplete/autocomplete_unittest.cc +++ b/chrome/browser/autocomplete/autocomplete_unittest.cc @@ -16,6 +16,8 @@ #include "chrome/common/notification_observer.h" #include "chrome/common/notification_registrar.h" #include "chrome/common/notification_service.h" +#include "chrome/test/testing_browser_process.h" +#include "chrome/test/testing_browser_process_test.h" #include "chrome/test/testing_profile.h" #include "testing/gtest/include/gtest/gtest.h" @@ -123,6 +125,8 @@ class AutocompleteProviderTest : public testing::Test, const NotificationSource& source, const NotificationDetails& details); + ScopedTestingBrowserProcess browser_process_; + MessageLoopForUI message_loop_; scoped_ptr<AutocompleteController> controller_; NotificationRegistrar registrar_; @@ -261,7 +265,9 @@ TEST_F(AutocompleteProviderTest, AllowExactKeywordMatch) { RunExactKeymatchTest(false); } -TEST(AutocompleteTest, InputType) { +typedef TestingBrowserProcessTest AutocompleteTest; + +TEST_F(AutocompleteTest, InputType) { struct test_data { const string16 input; const AutocompleteInput::Type type; @@ -358,7 +364,7 @@ TEST(AutocompleteTest, InputType) { } } -TEST(AutocompleteTest, InputTypeWithDesiredTLD) { +TEST_F(AutocompleteTest, InputTypeWithDesiredTLD) { struct test_data { const string16 input; const AutocompleteInput::Type type; @@ -377,7 +383,7 @@ TEST(AutocompleteTest, InputTypeWithDesiredTLD) { // This tests for a regression where certain input in the omnibox caused us to // crash. As long as the test completes without crashing, we're fine. -TEST(AutocompleteTest, InputCrash) { +TEST_F(AutocompleteTest, InputCrash) { AutocompleteInput input(WideToUTF16(L"\uff65@s"), string16(), true, false, true, false); } @@ -440,6 +446,8 @@ TEST(AutocompleteInput, ParseForEmphasizeComponent) { Component(12, 11), kInvalidComponent } }; + ScopedTestingBrowserProcess browser_process; + for (size_t i = 0; i < ARRAYSIZE_UNSAFE(input_cases); ++i) { Component scheme, host; AutocompleteInput::ParseForEmphasizeComponents(input_cases[i].input, |