summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorlevin@chromium.org <levin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-19 00:58:48 +0000
committerlevin@chromium.org <levin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-19 00:58:48 +0000
commit047f0593b4db9bb881a2e828b3bf9e3225d06da6 (patch)
treea657fda00ab5f06e42ad8ea9d25cf8a6b50f92e9 /chrome
parent45afd9a78d3316144d6702ff3cc230b4b76d76c7 (diff)
downloadchromium_src-047f0593b4db9bb881a2e828b3bf9e3225d06da6.zip
chromium_src-047f0593b4db9bb881a2e828b3bf9e3225d06da6.tar.gz
chromium_src-047f0593b4db9bb881a2e828b3bf9e3225d06da6.tar.bz2
Make the TemplateURL test code less likley to crash if various failures happen.
For example, if the test server fails to start, it would crash before these changes. BUG=None TEST=unit_tests -- gtest_filter=TemplateURL* (will run the affected tests). Review URL: http://codereview.chromium.org/3816008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@63004 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/search_engines/template_url_fetcher_unittest.cc4
-rw-r--r--chrome/browser/search_engines/template_url_model_test_util.cc11
2 files changed, 9 insertions, 6 deletions
diff --git a/chrome/browser/search_engines/template_url_fetcher_unittest.cc b/chrome/browser/search_engines/template_url_fetcher_unittest.cc
index 145b8df..737a349 100644
--- a/chrome/browser/search_engines/template_url_fetcher_unittest.cc
+++ b/chrome/browser/search_engines/template_url_fetcher_unittest.cc
@@ -47,15 +47,15 @@ class TemplateURLFetcherTest : public testing::Test {
TemplateURLFetcherTest();
virtual void SetUp() {
- ASSERT_TRUE(test_server_.Start());
-
test_util_.SetUp();
test_util_.StartIOThread();
+ ASSERT_TRUE(test_util_.profile());
test_util_.profile()->CreateTemplateURLFetcher();
ASSERT_TRUE(test_util_.profile()->GetTemplateURLFetcher());
test_util_.profile()->CreateRequestContext();
ASSERT_TRUE(test_util_.profile()->GetRequestContext());
+ ASSERT_TRUE(test_server_.Start());
}
virtual void TearDown() {
diff --git a/chrome/browser/search_engines/template_url_model_test_util.cc b/chrome/browser/search_engines/template_url_model_test_util.cc
index 73db65b..52a6c91 100644
--- a/chrome/browser/search_engines/template_url_model_test_util.cc
+++ b/chrome/browser/search_engines/template_url_model_test_util.cc
@@ -112,7 +112,7 @@ void TemplateURLModelTestingProfile::SetUp() {
FilePath path = temp_dir_.path().AppendASCII("TestDataService.db");
service_ = new WebDataService;
- EXPECT_TRUE(service_->InitWithPath(path));
+ ASSERT_TRUE(service_->InitWithPath(path));
}
void TemplateURLModelTestingProfile::TearDown() {
@@ -128,7 +128,8 @@ void TemplateURLModelTestingProfile::TearDown() {
io_thread_.Stop();
// Clean up the test directory.
- service_->Shutdown();
+ if (service_.get())
+ service_->Shutdown();
// Note that we must ensure the DB thread is stopped after WDS
// shutdown (so it can commit pending transactions) but before
// deleting the test profile directory, otherwise we may not be
@@ -152,8 +153,10 @@ void TemplateURLModelTestUtil::SetUp() {
}
void TemplateURLModelTestUtil::TearDown() {
- profile_->TearDown();
- profile_.reset();
+ if (profile_.get()) {
+ profile_->TearDown();
+ profile_.reset();
+ }
TemplateURLRef::SetGoogleBaseURL(NULL);
// Flush the message loop to make Purify happy.