diff options
author | rohitrao@chromium.org <rohitrao@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-25 19:38:38 +0000 |
---|---|---|
committer | rohitrao@chromium.org <rohitrao@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-25 19:38:38 +0000 |
commit | 4d230e3b61a996347cdb802de44c3122c4e0b6de (patch) | |
tree | ccea8683f30d5309d92c2d5cdd3e1f452ce33132 /base/test | |
parent | 3d86000f7f3ee120e62daba50fd5ccdf08cf09b5 (diff) | |
download | chromium_src-4d230e3b61a996347cdb802de44c3122c4e0b6de.zip chromium_src-4d230e3b61a996347cdb802de44c3122c4e0b6de.tar.gz chromium_src-4d230e3b61a996347cdb802de44c3122c4e0b6de.tar.bz2 |
Replace MessagePumpForUI with MessagePumpDefault in unit tests.
Uses the MessagePumpFactory functionality to install a default message pump in
unit tests. This allows us to stop hard-coding a default message pump in many
separate tests and instead centralizes the logic. When tests ask for a
MessageLoopForUI now, they will actually receive a message loop that is backed
by a default message pump, which means that calling Run() and Quit() will work
without crashing.
BUG=None
TEST=None
Review URL: https://chromiumcodereview.appspot.com/10701172
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@148384 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/test')
-rw-r--r-- | base/test/test_suite.cc | 8 | ||||
-rw-r--r-- | base/test/test_support_ios.h | 15 | ||||
-rw-r--r-- | base/test/test_support_ios.mm | 23 |
3 files changed, 46 insertions, 0 deletions
diff --git a/base/test/test_suite.cc b/base/test/test_suite.cc index 05a6069b..42edb00 100644 --- a/base/test/test_suite.cc +++ b/base/test/test_suite.cc @@ -36,6 +36,10 @@ #include "base/test/test_support_android.h" #endif +#if defined(OS_IOS) +#include "base/test/test_support_ios.h" +#endif + #if defined(TOOLKIT_GTK) #include <gtk/gtk.h> #endif @@ -303,6 +307,10 @@ void TestSuite::Initialize() { mock_cr_app::RegisterMockCrApp(); #endif +#if defined(OS_IOS) + InitIOSTestMessageLoop(); +#endif // OS_IOS + #if defined(OS_ANDROID) InitAndroidTest(); #else diff --git a/base/test/test_support_ios.h b/base/test/test_support_ios.h new file mode 100644 index 0000000..35b5b19 --- /dev/null +++ b/base/test/test_support_ios.h @@ -0,0 +1,15 @@ +// Copyright (c) 2012 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. + +#ifndef BASE_TEST_TEST_SUPPORT_IOS_H_ +#define BASE_TEST_TEST_SUPPORT_IOS_H_ + +namespace base { + +// Init the message loop for tests on iOS. +void InitIOSTestMessageLoop(); + +} // namespace base + +#endif // BASE_TEST_TEST_SUPPORT_IOS_H_ diff --git a/base/test/test_support_ios.mm b/base/test/test_support_ios.mm new file mode 100644 index 0000000..01b5158 --- /dev/null +++ b/base/test/test_support_ios.mm @@ -0,0 +1,23 @@ +// Copyright (c) 2012 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. + +#include "base/message_loop.h" +#include "base/message_pump_default.h" + +namespace { + +base::MessagePump* CreateMessagePumpForUIForTests() { + // A default MessagePump will do quite nicely in tests. + return new base::MessagePumpDefault(); +} + +} // namespace + +namespace base { + +void InitIOSTestMessageLoop() { + MessageLoop::InitMessagePumpForUIFactory(&CreateMessagePumpForUIForTests); +} + +} // namespace base |