summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorerg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-11 20:44:42 +0000
committererg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-11 20:44:42 +0000
commit5322a7f16a374a15fe69b3bb2621678aede48bca (patch)
tree56c8ee955ed32cd69f8b3395cb609dcdd504e58c /chrome/browser
parent192a05f2e4d8f66d095227439d4dce7bb14b16b5 (diff)
downloadchromium_src-5322a7f16a374a15fe69b3bb2621678aede48bca.zip
chromium_src-5322a7f16a374a15fe69b3bb2621678aede48bca.tar.gz
chromium_src-5322a7f16a374a15fe69b3bb2621678aede48bca.tar.bz2
Continuing with the out-of-lining of test code.
BUG=none TEST=compiles Review URL: http://codereview.chromium.org/6485015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@74660 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/extensions/extension_apitest.cc4
-rw-r--r--chrome/browser/extensions/extension_apitest.h4
-rw-r--r--chrome/browser/net/gaia/token_service_unittest.cc57
-rw-r--r--chrome/browser/net/gaia/token_service_unittest.h56
-rw-r--r--chrome/browser/notifications/desktop_notifications_unittest.cc4
-rw-r--r--chrome/browser/notifications/desktop_notifications_unittest.h5
-rw-r--r--chrome/browser/renderer_host/pepper_message_filter.cc2
-rw-r--r--chrome/browser/renderer_host/pepper_message_filter.h1
8 files changed, 80 insertions, 53 deletions
diff --git a/chrome/browser/extensions/extension_apitest.cc b/chrome/browser/extensions/extension_apitest.cc
index 8ff88e8..744c142 100644
--- a/chrome/browser/extensions/extension_apitest.cc
+++ b/chrome/browser/extensions/extension_apitest.cc
@@ -19,6 +19,10 @@ const char kTestServerPort[] = "testServer.port";
}; // namespace
+ExtensionApiTest::ExtensionApiTest() {}
+
+ExtensionApiTest::~ExtensionApiTest() {}
+
ExtensionApiTest::ResultCatcher::ResultCatcher()
: profile_restriction_(NULL),
waiting_(false) {
diff --git a/chrome/browser/extensions/extension_apitest.h b/chrome/browser/extensions/extension_apitest.h
index f3176b5..e7d2af6 100644
--- a/chrome/browser/extensions/extension_apitest.h
+++ b/chrome/browser/extensions/extension_apitest.h
@@ -25,6 +25,10 @@ class Extension;
// TODO(erikkay): There should also be a way to drive events in these tests.
class ExtensionApiTest : public ExtensionBrowserTest {
+ public:
+ ExtensionApiTest();
+ virtual ~ExtensionApiTest();
+
protected:
// Helper class that observes tests failing or passing. Observation starts
// when the class is constructed. Get the next result by calling
diff --git a/chrome/browser/net/gaia/token_service_unittest.cc b/chrome/browser/net/gaia/token_service_unittest.cc
index d06956f..8650442 100644
--- a/chrome/browser/net/gaia/token_service_unittest.cc
+++ b/chrome/browser/net/gaia/token_service_unittest.cc
@@ -7,11 +7,68 @@
#include "chrome/browser/net/gaia/token_service_unittest.h"
#include "base/command_line.h"
+#include "chrome/browser/password_manager/encryptor.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/net/gaia/gaia_auth_fetcher_unittest.h"
#include "chrome/common/net/gaia/gaia_constants.h"
#include "chrome/common/net/test_url_fetcher_factory.h"
+TokenServiceTestHarness::TokenServiceTestHarness()
+ : ui_thread_(BrowserThread::UI, &message_loop_),
+ db_thread_(BrowserThread::DB) {
+}
+
+TokenServiceTestHarness::~TokenServiceTestHarness() {}
+
+void TokenServiceTestHarness::SetUp() {
+#if defined(OS_MACOSX)
+ Encryptor::UseMockKeychain(true);
+#endif
+ credentials_.sid = "sid";
+ credentials_.lsid = "lsid";
+ credentials_.token = "token";
+ credentials_.data = "data";
+
+ ASSERT_TRUE(db_thread_.Start());
+
+ profile_.reset(new TestingProfile());
+ profile_->CreateWebDataService(false);
+ WaitForDBLoadCompletion();
+
+ success_tracker_.ListenFor(NotificationType::TOKEN_AVAILABLE,
+ Source<TokenService>(&service_));
+ failure_tracker_.ListenFor(NotificationType::TOKEN_REQUEST_FAILED,
+ Source<TokenService>(&service_));
+
+ service_.Initialize("test", profile_.get());
+
+ URLFetcher::set_factory(NULL);
+}
+
+void TokenServiceTestHarness::TearDown() {
+ // You have to destroy the profile before the db_thread_ stops.
+ if (profile_.get()) {
+ profile_.reset(NULL);
+ }
+
+ db_thread_.Stop();
+ MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask);
+ MessageLoop::current()->Run();
+}
+
+void TokenServiceTestHarness::WaitForDBLoadCompletion() {
+ // The WebDB does all work on the DB thread. This will add an event
+ // to the end of the DB thread, so when we reach this task, all DB
+ // operations should be complete.
+ WaitableEvent done(false, false);
+ BrowserThread::PostTask(
+ BrowserThread::DB, FROM_HERE, new SignalingTask(&done));
+ done.Wait();
+
+ // Notifications should be returned from the DB thread onto the UI thread.
+ message_loop_.RunAllPending();
+}
+
class TokenServiceTest : public TokenServiceTestHarness {
public:
virtual void SetUp() {
diff --git a/chrome/browser/net/gaia/token_service_unittest.h b/chrome/browser/net/gaia/token_service_unittest.h
index 46cffb0c..9481d22 100644
--- a/chrome/browser/net/gaia/token_service_unittest.h
+++ b/chrome/browser/net/gaia/token_service_unittest.h
@@ -9,7 +9,6 @@
#pragma once
#include "chrome/browser/net/gaia/token_service.h"
-#include "chrome/browser/password_manager/encryptor.h"
#include "chrome/browser/webdata/web_data_service.h"
#include "chrome/common/net/gaia/gaia_auth_consumer.h"
#include "chrome/common/notification_details.h"
@@ -64,59 +63,14 @@ class TokenFailedTracker : public TestNotificationTracker {
class TokenServiceTestHarness : public testing::Test {
public:
- TokenServiceTestHarness()
- : ui_thread_(BrowserThread::UI, &message_loop_),
- db_thread_(BrowserThread::DB) {
- }
-
- virtual void SetUp() {
-#if defined(OS_MACOSX)
- Encryptor::UseMockKeychain(true);
-#endif
- credentials_.sid = "sid";
- credentials_.lsid = "lsid";
- credentials_.token = "token";
- credentials_.data = "data";
-
- ASSERT_TRUE(db_thread_.Start());
-
- profile_.reset(new TestingProfile());
- profile_->CreateWebDataService(false);
- WaitForDBLoadCompletion();
-
- success_tracker_.ListenFor(NotificationType::TOKEN_AVAILABLE,
- Source<TokenService>(&service_));
- failure_tracker_.ListenFor(NotificationType::TOKEN_REQUEST_FAILED,
- Source<TokenService>(&service_));
-
- service_.Initialize("test", profile_.get());
+ TokenServiceTestHarness();
+ virtual ~TokenServiceTestHarness();
- URLFetcher::set_factory(NULL);
- }
-
- virtual void TearDown() {
- // You have to destroy the profile before the db_thread_ stops.
- if (profile_.get()) {
- profile_.reset(NULL);
- }
+ virtual void SetUp();
- db_thread_.Stop();
- MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask);
- MessageLoop::current()->Run();
- }
-
- void WaitForDBLoadCompletion() {
- // The WebDB does all work on the DB thread. This will add an event
- // to the end of the DB thread, so when we reach this task, all DB
- // operations should be complete.
- WaitableEvent done(false, false);
- BrowserThread::PostTask(
- BrowserThread::DB, FROM_HERE, new SignalingTask(&done));
- done.Wait();
+ virtual void TearDown();
- // Notifications should be returned from the DB thread onto the UI thread.
- message_loop_.RunAllPending();
- }
+ void WaitForDBLoadCompletion();
MessageLoopForUI message_loop_;
BrowserThread ui_thread_; // Mostly so DCHECKS pass.
diff --git a/chrome/browser/notifications/desktop_notifications_unittest.cc b/chrome/browser/notifications/desktop_notifications_unittest.cc
index 457b135..6effdf1 100644
--- a/chrome/browser/notifications/desktop_notifications_unittest.cc
+++ b/chrome/browser/notifications/desktop_notifications_unittest.cc
@@ -17,6 +17,10 @@ const int MockBalloonCollection::kMockBalloonSpace = 5;
// static
std::string DesktopNotificationsTest::log_output_;
+MockBalloonCollection::MockBalloonCollection() {}
+
+MockBalloonCollection::~MockBalloonCollection() {}
+
void MockBalloonCollection::Add(const Notification& notification,
Profile* profile) {
// Swap in a logging proxy for the purpose of logging calls that
diff --git a/chrome/browser/notifications/desktop_notifications_unittest.h b/chrome/browser/notifications/desktop_notifications_unittest.h
index 4ddee80..25e5270 100644
--- a/chrome/browser/notifications/desktop_notifications_unittest.h
+++ b/chrome/browser/notifications/desktop_notifications_unittest.h
@@ -28,7 +28,8 @@ typedef LoggingNotificationDelegate<DesktopNotificationsTest>
// of notifications that are added to it.
class MockBalloonCollection : public BalloonCollectionImpl {
public:
- MockBalloonCollection() {}
+ MockBalloonCollection();
+ virtual ~MockBalloonCollection();
// Our mock collection has an area large enough for a fixed number
// of balloons.
@@ -70,7 +71,7 @@ class MockBalloonCollection : public BalloonCollectionImpl {
class DesktopNotificationsTest : public testing::Test {
public:
DesktopNotificationsTest();
- ~DesktopNotificationsTest();
+ virtual ~DesktopNotificationsTest();
static void log(const std::string& message) {
log_output_.append(message);
diff --git a/chrome/browser/renderer_host/pepper_message_filter.cc b/chrome/browser/renderer_host/pepper_message_filter.cc
index edafa05..de0793d 100644
--- a/chrome/browser/renderer_host/pepper_message_filter.cc
+++ b/chrome/browser/renderer_host/pepper_message_filter.cc
@@ -38,6 +38,8 @@ PepperMessageFilter::PepperMessageFilter(Profile* profile)
request_context_(profile_->GetRequestContext()) {
}
+PepperMessageFilter::~PepperMessageFilter() {}
+
bool PepperMessageFilter::OnMessageReceived(const IPC::Message& msg,
bool* message_was_ok) {
#if defined(ENABLE_FLAPPER_HACKS)
diff --git a/chrome/browser/renderer_host/pepper_message_filter.h b/chrome/browser/renderer_host/pepper_message_filter.h
index 0e2284d..17ccf11 100644
--- a/chrome/browser/renderer_host/pepper_message_filter.h
+++ b/chrome/browser/renderer_host/pepper_message_filter.h
@@ -24,6 +24,7 @@ class AddressList;
class PepperMessageFilter : public BrowserMessageFilter {
public:
explicit PepperMessageFilter(Profile* profile);
+ virtual ~PepperMessageFilter();
private:
// BrowserMessageFilter methods.