diff options
author | leng@chromium.org <leng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-18 08:06:50 +0000 |
---|---|---|
committer | leng@chromium.org <leng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-18 08:06:50 +0000 |
commit | 840246b68b70b0d1faa5d19d552daaa3b361189e (patch) | |
tree | 8dc0641fdac11e9c7b431d372c0eca64686365dd /base | |
parent | e97039447d13035eee09297baf172c6ca46ec9bd (diff) | |
download | chromium_src-840246b68b70b0d1faa5d19d552daaa3b361189e.zip chromium_src-840246b68b70b0d1faa5d19d552daaa3b361189e.tar.gz chromium_src-840246b68b70b0d1faa5d19d552daaa3b361189e.tar.bz2 |
Change explicit usage of each type of message loop in WaitableEventWatcher tests to instead loop through an array of message loop types.
This allows for easier-to-read code while including a platform that cannot run the tests on every kind of message loop. Specifically, iOS cannot run the UI loop for unit tests.
Un-exclude synchronization/waitable_event_watcher_unittest.cc on ios in base.gyp.
BUG=b/6825256
TEST=None
Review URL: https://chromiumcodereview.appspot.com/10790028
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@147198 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r-- | base/base.gyp | 1 | ||||
-rw-r--r-- | base/synchronization/waitable_event_watcher_unittest.cc | 41 |
2 files changed, 26 insertions, 16 deletions
diff --git a/base/base.gyp b/base/base.gyp index 9767a5b..ecaa2b4 100644 --- a/base/base.gyp +++ b/base/base.gyp @@ -570,7 +570,6 @@ ['exclude', '^memory/aligned_memory_unittest\\.cc$'], # Unittests that don't pass. ['exclude', '^message_loop_unittest\\.cc$'], - ['exclude', '^synchronization/waitable_event_watcher_unittest\\.cc$'], ], 'actions': [ { diff --git a/base/synchronization/waitable_event_watcher_unittest.cc b/base/synchronization/waitable_event_watcher_unittest.cc index c48333a..8fa4e7b 100644 --- a/base/synchronization/waitable_event_watcher_unittest.cc +++ b/base/synchronization/waitable_event_watcher_unittest.cc @@ -12,6 +12,17 @@ namespace base { namespace { +// The message loops on which each waitable event timer should be tested. +const MessageLoop::Type testing_message_loops[] = { + MessageLoop::TYPE_DEFAULT, + MessageLoop::TYPE_IO, +#if !defined(OS_IOS) // iOS does not allow direct running of the UI loop. + MessageLoop::TYPE_UI, +#endif +}; + +const int kNumTestingMessageLoops = arraysize(testing_message_loops); + class QuitDelegate : public WaitableEventWatcher::Delegate { public: virtual void OnWaitableEventSignaled(WaitableEvent* event) OVERRIDE { @@ -127,27 +138,27 @@ void RunTest_DeleteUnder(MessageLoop::Type message_loop_type) { //----------------------------------------------------------------------------- TEST(WaitableEventWatcherTest, BasicSignal) { - RunTest_BasicSignal(MessageLoop::TYPE_DEFAULT); - RunTest_BasicSignal(MessageLoop::TYPE_IO); - RunTest_BasicSignal(MessageLoop::TYPE_UI); + for (int i = 0; i < kNumTestingMessageLoops; i++) { + RunTest_BasicSignal(testing_message_loops[i]); + } } TEST(WaitableEventWatcherTest, BasicCancel) { - RunTest_BasicCancel(MessageLoop::TYPE_DEFAULT); - RunTest_BasicCancel(MessageLoop::TYPE_IO); - RunTest_BasicCancel(MessageLoop::TYPE_UI); + for (int i = 0; i < kNumTestingMessageLoops; i++) { + RunTest_BasicCancel(testing_message_loops[i]); + } } TEST(WaitableEventWatcherTest, CancelAfterSet) { - RunTest_CancelAfterSet(MessageLoop::TYPE_DEFAULT); - RunTest_CancelAfterSet(MessageLoop::TYPE_IO); - RunTest_CancelAfterSet(MessageLoop::TYPE_UI); + for (int i = 0; i < kNumTestingMessageLoops; i++) { + RunTest_CancelAfterSet(testing_message_loops[i]); + } } TEST(WaitableEventWatcherTest, OutlivesMessageLoop) { - RunTest_OutlivesMessageLoop(MessageLoop::TYPE_DEFAULT); - RunTest_OutlivesMessageLoop(MessageLoop::TYPE_IO); - RunTest_OutlivesMessageLoop(MessageLoop::TYPE_UI); + for (int i = 0; i < kNumTestingMessageLoops; i++) { + RunTest_OutlivesMessageLoop(testing_message_loops[i]); + } } #if defined(OS_WIN) @@ -157,9 +168,9 @@ TEST(WaitableEventWatcherTest, OutlivesMessageLoop) { #define MAYBE_DeleteUnder DeleteUnder #endif TEST(WaitableEventWatcherTest, MAYBE_DeleteUnder) { - RunTest_DeleteUnder(MessageLoop::TYPE_DEFAULT); - RunTest_DeleteUnder(MessageLoop::TYPE_IO); - RunTest_DeleteUnder(MessageLoop::TYPE_UI); + for (int i = 0; i < kNumTestingMessageLoops; i++) { + RunTest_DeleteUnder(testing_message_loops[i]); + } } } // namespace base |