Delete unused downloads page asset.
[chromium-blink-merge.git] / ppapi / tests / test_flash_message_loop.cc
blobe7cb3186915b1e296ab29e3f19bc6e6a843581b5
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)
17 : TestCase(instance),
18 message_loop_(NULL),
19 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_);
40 delete message_loop_;
41 message_loop_ = NULL;
43 ASSERT_EQ(PP_OK, result);
44 PASS();
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();
55 if (message_loop_) {
56 delete message_loop_;
57 message_loop_ = NULL;
58 ASSERT_TRUE(false);
61 ASSERT_EQ(PP_ERROR_ABORTED, result);
62 PASS();
65 void TestFlashMessageLoop::QuitMessageLoopTask(int32_t unused) {
66 if (message_loop_)
67 message_loop_->Quit();
68 else
69 PP_NOTREACHED();
72 void TestFlashMessageLoop::DestroyMessageLoopResourceTask(int32_t unused) {
73 if (message_loop_) {
74 delete message_loop_;
75 message_loop_ = NULL;
76 } else {
77 PP_NOTREACHED();