Commit 4d230e3b authored by rohitrao@chromium.org's avatar rohitrao@chromium.org

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
parent 3d86000f
......@@ -718,6 +718,8 @@
'test/test_suite.h',
'test/test_support_android.cc',
'test/test_support_android.h',
'test/test_support_ios.h',
'test/test_support_ios.mm',
'test/test_switches.cc',
'test/test_switches.h',
'test/test_timeouts.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
......
// 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_
// 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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment