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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: ppapi/tests/test_flash_message_loop.cc
diff --git a/ppapi/tests/test_flash_message_loop.cc b/ppapi/tests/test_flash_message_loop.cc
new file mode 100644
index 0000000000000000000000000000000000000000..5143fe78d170f09743845d964b37e87555e3e30b
--- /dev/null
+++ b/ppapi/tests/test_flash_message_loop.cc
@@ -0,0 +1,81 @@
+// Copyright (c) 2012 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.
+
+#include "ppapi/tests/test_flash_message_loop.h"
+
+#include "ppapi/c/pp_macros.h"
+#include "ppapi/cpp/core.h"
+#include "ppapi/cpp/logging.h"
+#include "ppapi/cpp/module.h"
+#include "ppapi/cpp/private/flash_message_loop.h"
+#include "ppapi/tests/testing_instance.h"
+
+REGISTER_TEST_CASE(FlashMessageLoop);
+
+TestFlashMessageLoop::TestFlashMessageLoop(TestingInstance* instance)
+ : TestCase(instance),
+ message_loop_(NULL),
+ PP_ALLOW_THIS_IN_INITIALIZER_LIST(callback_factory_(this)) {
+}
+
+TestFlashMessageLoop::~TestFlashMessageLoop() {
+ PP_DCHECK(!message_loop_);
+}
+
+void TestFlashMessageLoop::RunTests(const std::string& filter) {
+ RUN_TEST(Basics, filter);
+ RUN_TEST(RunWithoutQuit, filter);
+}
+
+std::string TestFlashMessageLoop::TestBasics() {
+ message_loop_ = new pp::flash::MessageLoop(instance_);
+
+ pp::CompletionCallback callback =
+ callback_factory_.NewRequiredCallback(
+ &TestFlashMessageLoop::QuitMessageLoopTask);
+ pp::Module::Get()->core()->CallOnMainThread(0, callback);
+ int32_t result = message_loop_->Run();
+
+ ASSERT_TRUE(message_loop_);
+ delete message_loop_;
+ message_loop_ = NULL;
+
+ ASSERT_EQ(result, PP_OK);
+ PASS();
+}
+
+std::string TestFlashMessageLoop::TestRunWithoutQuit() {
+ message_loop_ = new pp::flash::MessageLoop(instance_);
+
+ pp::CompletionCallback callback =
+ callback_factory_.NewRequiredCallback(
+ &TestFlashMessageLoop::DestroyMessageLoopResourceTask);
+ pp::Module::Get()->core()->CallOnMainThread(0, callback);
+ int32_t result = message_loop_->Run();
+
+ if (message_loop_) {
+ delete message_loop_;
+ message_loop_ = NULL;
+ ASSERT_TRUE(false);
+ }
+
+ ASSERT_EQ(result, PP_ERROR_ABORTED);
+ PASS();
+}
+
+void TestFlashMessageLoop::QuitMessageLoopTask(int32_t unused) {
+ if (message_loop_)
+ message_loop_->Quit();
+ else
+ PP_NOTREACHED();
+}
+
+void TestFlashMessageLoop::DestroyMessageLoopResourceTask(int32_t unused) {
+ if (message_loop_) {
+ delete message_loop_;
+ message_loop_ = NULL;
+ } else {
+ PP_NOTREACHED();
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698