1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ppapi/tests/test_flash_message_loop.h"
7 #include "ppapi/c/pp_macros.h"
8 #include "ppapi/cpp/core.h"
9 #include "ppapi/cpp/logging.h"
10 #include "ppapi/cpp/module.h"
11 #include "ppapi/cpp/private/flash_message_loop.h"
12 #include "ppapi/tests/testing_instance.h"
14 REGISTER_TEST_CASE(FlashMessageLoop
);
16 TestFlashMessageLoop::TestFlashMessageLoop(TestingInstance
* instance
)
19 PP_ALLOW_THIS_IN_INITIALIZER_LIST(callback_factory_(this)) {
22 TestFlashMessageLoop::~TestFlashMessageLoop() {
23 PP_DCHECK(!message_loop_
);
26 void TestFlashMessageLoop::RunTests(const std::string
& filter
) {
27 RUN_TEST(Basics
, filter
);
28 RUN_TEST(RunWithoutQuit
, filter
);
31 std::string
TestFlashMessageLoop::TestBasics() {
32 message_loop_
= new pp::flash::MessageLoop(instance_
);
34 pp::CompletionCallback callback
= callback_factory_
.NewCallback(
35 &TestFlashMessageLoop::QuitMessageLoopTask
);
36 pp::Module::Get()->core()->CallOnMainThread(0, callback
);
37 int32_t result
= message_loop_
->Run();
39 ASSERT_TRUE(message_loop_
);
43 ASSERT_EQ(PP_OK
, result
);
47 std::string
TestFlashMessageLoop::TestRunWithoutQuit() {
48 message_loop_
= new pp::flash::MessageLoop(instance_
);
50 pp::CompletionCallback callback
= callback_factory_
.NewCallback(
51 &TestFlashMessageLoop::DestroyMessageLoopResourceTask
);
52 pp::Module::Get()->core()->CallOnMainThread(0, callback
);
53 int32_t result
= message_loop_
->Run();
61 ASSERT_EQ(PP_ERROR_ABORTED
, result
);
65 void TestFlashMessageLoop::QuitMessageLoopTask(int32_t unused
) {
67 message_loop_
->Quit();
72 void TestFlashMessageLoop::DestroyMessageLoopResourceTask(int32_t unused
) {