diff options
author | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-12 16:35:02 +0000 |
---|---|---|
committer | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-12 16:35:02 +0000 |
commit | 3fee57b39da2e99e44d65021263d057a7b239683 (patch) | |
tree | 06f7887456a61bc27f04a2a1965925ef3713c76e /base/message_loop/message_loop_test.h | |
parent | 660e19c045e1cd43fe64f0adb8caf678143a461b (diff) | |
download | chromium_src-3fee57b39da2e99e44d65021263d057a7b239683.zip chromium_src-3fee57b39da2e99e44d65021263d057a7b239683.tar.gz chromium_src-3fee57b39da2e99e44d65021263d057a7b239683.tar.bz2 |
Implementation of MessagePump for Mojo.
I've refactored a bunch of the common MessagePump code into
message_pump_test. This allows us to share tests for custom
messagePumps and should allow moving MessagePumpForUI out later
on. Sadly it results in a ginormous macro. On the positive side it's
easy to use.
BUG=none
TEST=none
R=darin@chromium.org
Review URL: https://codereview.chromium.org/66193007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@234540 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/message_loop/message_loop_test.h')
-rw-r--r-- | base/message_loop/message_loop_test.h | 137 |
1 files changed, 137 insertions, 0 deletions
diff --git a/base/message_loop/message_loop_test.h b/base/message_loop/message_loop_test.h new file mode 100644 index 0000000..5d1a4f5 --- /dev/null +++ b/base/message_loop/message_loop_test.h @@ -0,0 +1,137 @@ +// Copyright 2013 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_MESSAGE_LOOP_MESSAGE_LOOP_TEST_H_ +#define BASE_MESSAGE_LOOP_MESSAGE_LOOP_TEST_H_ + +#include "base/message_loop/message_loop.h" +#include "testing/gtest/include/gtest/gtest.h" + +// This file consists of tests meant to exercise the combination of MessageLoop +// and MessagePump. To use these define the macro RUN_MESSAGE_LOOP_TESTS using +// an ID appropriate for your MessagePump, eg +// RUN_MESSAGE_LOOP_TESTS(UI, factory). Factory is a function called to create +// the MessagePump. +namespace base { +namespace test { + +typedef MessageLoop::MessagePumpFactory MessagePumpFactory; + +void RunTest_PostTask(MessagePumpFactory factory); +void RunTest_PostTask_SEH(MessagePumpFactory factory); +void RunTest_PostDelayedTask_Basic(MessagePumpFactory factory); +void RunTest_PostDelayedTask_InDelayOrder(MessagePumpFactory factory); +void RunTest_PostDelayedTask_InPostOrder(MessagePumpFactory factory); +void RunTest_PostDelayedTask_InPostOrder_2(MessagePumpFactory factory); +void RunTest_PostDelayedTask_InPostOrder_3(MessagePumpFactory factory); +void RunTest_PostDelayedTask_SharedTimer(MessagePumpFactory factory); +void RunTest_EnsureDeletion(MessagePumpFactory factory); +void RunTest_EnsureDeletion_Chain(MessagePumpFactory factory); +void RunTest_Nesting(MessagePumpFactory factory); +void RunTest_RecursiveDenial1(MessagePumpFactory factory); +void RunTest_RecursiveDenial3(MessagePumpFactory factory); +void RunTest_RecursiveSupport1(MessagePumpFactory factory); +void RunTest_NonNestableWithNoNesting(MessagePumpFactory factory); +void RunTest_NonNestableInNestedLoop(MessagePumpFactory factory, + bool use_delayed); +void RunTest_QuitNow(MessagePumpFactory factory); +void RunTest_RunLoopQuitTop(MessagePumpFactory factory); +void RunTest_RunLoopQuitNested(MessagePumpFactory factory); +void RunTest_RunLoopQuitBogus(MessagePumpFactory factory); +void RunTest_RunLoopQuitDeep(MessagePumpFactory factory); +void RunTest_RunLoopQuitOrderBefore(MessagePumpFactory factory); +void RunTest_RunLoopQuitOrderDuring(MessagePumpFactory factory); +void RunTest_RunLoopQuitOrderAfter(MessagePumpFactory factory); +void RunTest_RecursivePosts(MessagePumpFactory factory); + +} // namespace test +} // namespace base + +#define RUN_MESSAGE_LOOP_TESTS(id, factory) \ + TEST(MessageLoopTestType##id, PostTask) { \ + base::test::RunTest_PostTask(factory); \ + } \ + TEST(MessageLoopTestType##id, PostTask_SEH) { \ + base::test::RunTest_PostTask_SEH(factory); \ + } \ + TEST(MessageLoopTestType##id, PostDelayedTask_Basic) { \ + base::test::RunTest_PostDelayedTask_Basic(factory); \ + } \ + TEST(MessageLoopTestType##id, PostDelayedTask_InDelayOrder) { \ + base::test::RunTest_PostDelayedTask_InDelayOrder(factory); \ + } \ + TEST(MessageLoopTestType##id, PostDelayedTask_InPostOrder) { \ + base::test::RunTest_PostDelayedTask_InPostOrder(factory); \ + } \ + TEST(MessageLoopTestType##id, PostDelayedTask_InPostOrder_2) { \ + base::test::RunTest_PostDelayedTask_InPostOrder_2(factory); \ + } \ + TEST(MessageLoopTestType##id, PostDelayedTask_InPostOrder_3) { \ + base::test::RunTest_PostDelayedTask_InPostOrder_3(factory); \ + } \ + TEST(MessageLoopTestType##id, PostDelayedTask_SharedTimer) { \ + base::test::RunTest_PostDelayedTask_SharedTimer(factory); \ + } \ + /* TODO(darin): MessageLoop does not support deleting all tasks in the */ \ + /* destructor. */ \ + /* Fails, http://crbug.com/50272. */ \ + TEST(MessageLoopTestType##id, DISABLED_EnsureDeletion) { \ + base::test::RunTest_EnsureDeletion(factory); \ + } \ + /* TODO(darin): MessageLoop does not support deleting all tasks in the */ \ + /* destructor. */ \ + /* Fails, http://crbug.com/50272. */ \ + TEST(MessageLoopTestType##id, DISABLED_EnsureDeletion_Chain) { \ + base::test::RunTest_EnsureDeletion_Chain(factory); \ + } \ + TEST(MessageLoopTestType##id, Nesting) { \ + base::test::RunTest_Nesting(factory); \ + } \ + TEST(MessageLoopTestType##id, RecursiveDenial1) { \ + base::test::RunTest_RecursiveDenial1(factory); \ + } \ + TEST(MessageLoopTestType##id, RecursiveDenial3) { \ + base::test::RunTest_RecursiveDenial3(factory); \ + } \ + TEST(MessageLoopTestType##id, RecursiveSupport1) { \ + base::test::RunTest_RecursiveSupport1(factory); \ + } \ + TEST(MessageLoopTestType##id, NonNestableWithNoNesting) { \ + base::test::RunTest_NonNestableWithNoNesting(factory); \ + } \ + TEST(MessageLoopTestType##id, NonNestableInNestedLoop) { \ + base::test::RunTest_NonNestableInNestedLoop(factory, false); \ + } \ + TEST(MessageLoopTestType##id, NonNestableDelayedInNestedLoop) { \ + base::test::RunTest_NonNestableInNestedLoop(factory, true); \ + } \ + TEST(MessageLoopTestType##id, QuitNow) { \ + base::test::RunTest_QuitNow(factory); \ + } \ + TEST(MessageLoopTestType##id, RunLoopQuitTop) { \ + base::test::RunTest_RunLoopQuitTop(factory); \ + } \ + TEST(MessageLoopTestType##id, RunLoopQuitNested) { \ + base::test::RunTest_RunLoopQuitNested(factory); \ + } \ + TEST(MessageLoopTestType##id, RunLoopQuitBogus) { \ + base::test::RunTest_RunLoopQuitBogus(factory); \ + } \ + TEST(MessageLoopTestType##id, RunLoopQuitDeep) { \ + base::test::RunTest_RunLoopQuitDeep(factory); \ + } \ + TEST(MessageLoopTestType##id, RunLoopQuitOrderBefore) { \ + base::test::RunTest_RunLoopQuitOrderBefore(factory); \ + } \ + TEST(MessageLoopTestType##id, RunLoopQuitOrderDuring) { \ + base::test::RunTest_RunLoopQuitOrderDuring(factory); \ + } \ + TEST(MessageLoopTestType##id, RunLoopQuitOrderAfter) { \ + base::test::RunTest_RunLoopQuitOrderAfter(factory); \ + } \ + TEST(MessageLoopTestType##id, RecursivePosts) { \ + base::test::RunTest_RecursivePosts(factory); \ + } \ + +#endif // BASE_MESSAGE_LOOP_MESSAGE_LOOP_TEST_H_ |