Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(546)

Side by Side Diff: ppapi/tests/test_flash_message_loop.cc

Issue 9188045: Introduce PPB_Flash_MessageLoop interface for Pepper Flash. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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.
4
5 #include "ppapi/tests/test_flash_message_loop.h"
6
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"
13
14 REGISTER_TEST_CASE(FlashMessageLoop);
15
16 TestFlashMessageLoop::TestFlashMessageLoop(TestingInstance* instance)
17 : TestCase(instance),
18 message_loop_(NULL),
19 PP_ALLOW_THIS_IN_INITIALIZER_LIST(callback_factory_(this)) {
20 }
21
22 TestFlashMessageLoop::~TestFlashMessageLoop() {
23 PP_DCHECK(!message_loop_);
24 }
25
26 void TestFlashMessageLoop::RunTests(const std::string& filter) {
27 RUN_TEST(Basics, filter);
28 RUN_TEST(RunWithoutQuit, filter);
29 }
30
31 std::string TestFlashMessageLoop::TestBasics() {
32 message_loop_ = new pp::flash::MessageLoop(instance_);
33
34 pp::CompletionCallback callback =
35 callback_factory_.NewRequiredCallback(
36 &TestFlashMessageLoop::QuitMessageLoopTask);
37 pp::Module::Get()->core()->CallOnMainThread(0, callback);
38 int32_t result = message_loop_->Run();
39
40 ASSERT_TRUE(message_loop_);
41 delete message_loop_;
42 message_loop_ = NULL;
43
44 ASSERT_EQ(result, PP_OK);
45 PASS();
46 }
47
48 std::string TestFlashMessageLoop::TestRunWithoutQuit() {
49 message_loop_ = new pp::flash::MessageLoop(instance_);
50
51 pp::CompletionCallback callback =
52 callback_factory_.NewRequiredCallback(
53 &TestFlashMessageLoop::DestroyMessageLoopResourceTask);
54 pp::Module::Get()->core()->CallOnMainThread(0, callback);
55 int32_t result = message_loop_->Run();
56
57 if (message_loop_) {
58 delete message_loop_;
59 message_loop_ = NULL;
60 ASSERT_TRUE(false);
61 }
62
63 ASSERT_EQ(result, PP_ERROR_ABORTED);
64 PASS();
65 }
66
67 void TestFlashMessageLoop::QuitMessageLoopTask(int32_t unused) {
68 if (message_loop_)
69 message_loop_->Quit();
70 else
71 PP_NOTREACHED();
72 }
73
74 void TestFlashMessageLoop::DestroyMessageLoopResourceTask(int32_t unused) {
75 if (message_loop_) {
76 delete message_loop_;
77 message_loop_ = NULL;
78 } else {
79 PP_NOTREACHED();
80 }
81 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698