diff options
author | jhorwich@chromium.org <jhorwich@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-16 07:31:25 +0000 |
---|---|---|
committer | jhorwich@chromium.org <jhorwich@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-16 07:31:25 +0000 |
commit | e98aebff68b356aaec06ff09474d8e2d51a25984 (patch) | |
tree | 84ce4cd0ed776dd87df294b19b10b39d7f6b6def /ppapi | |
parent | 036ff0d192ea599c00ed4974a156fa19a7adae75 (diff) | |
download | chromium_src-e98aebff68b356aaec06ff09474d8e2d51a25984.zip chromium_src-e98aebff68b356aaec06ff09474d8e2d51a25984.tar.gz chromium_src-e98aebff68b356aaec06ff09474d8e2d51a25984.tar.bz2 |
Add ppapi_test for ppb_talk_private
Adding a test for ppb_talk_private's GetPermission API. This should be helpful
for http://codereview.chromium.org/11359147/
BUG=
Review URL: https://chromiumcodereview.appspot.com/11419023
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@168146 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r-- | ppapi/ppapi_sources.gypi | 2 | ||||
-rw-r--r-- | ppapi/tests/test_talk_private.cc | 85 | ||||
-rw-r--r-- | ppapi/tests/test_talk_private.h | 27 |
3 files changed, 114 insertions, 0 deletions
diff --git a/ppapi/ppapi_sources.gypi b/ppapi/ppapi_sources.gypi index 7a871e6..55608ae 100644 --- a/ppapi/ppapi_sources.gypi +++ b/ppapi/ppapi_sources.gypi @@ -454,6 +454,8 @@ 'tests/test_resource_array.cc', 'tests/test_resource_array.h', 'tests/test_struct_sizes.c', + 'tests/test_talk_private.cc', + 'tests/test_talk_private.h', 'tests/test_tcp_socket_private_trusted.cc', 'tests/test_tcp_socket_private_trusted.h', 'tests/test_uma.cc', diff --git a/ppapi/tests/test_talk_private.cc b/ppapi/tests/test_talk_private.cc new file mode 100644 index 0000000..4b49ed1 --- /dev/null +++ b/ppapi/tests/test_talk_private.cc @@ -0,0 +1,85 @@ +// 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_talk_private.h" + +#include <stdio.h> +#include <string.h> +#include <string> + +#include "ppapi/c/dev/ppb_testing_dev.h" +#include "ppapi/c/pp_errors.h" +#include "ppapi/c/private/ppb_talk_private.h" +#include "ppapi/cpp/instance.h" +#include "ppapi/cpp/module.h" +#include "ppapi/tests/test_utils.h" +#include "ppapi/tests/testing_instance.h" + +REGISTER_TEST_CASE(TalkPrivate); + +TestTalkPrivate::TestTalkPrivate(TestingInstance* instance) + : TestCase(instance), + talk_private_interface_(NULL) { +} + +bool TestTalkPrivate::Init() { + if (!CheckTestingInterface()) { + instance_->AppendError("Testing interface not available"); + return false; + } + + talk_private_interface_ = static_cast<const PPB_Talk_Private*>( + pp::Module::Get()->GetBrowserInterface(PPB_TALK_PRIVATE_INTERFACE)); + +#if defined(__native_client__) + if (talk_private_interface_) + instance_->AppendError("TalkPrivate interface is supported by NaCl"); +#else + if (!talk_private_interface_) + instance_->AppendError("TalkPrivate interface not available"); +#endif + return true; +} + +void TestTalkPrivate::RunTests(const std::string& filter) { + RUN_CALLBACK_TEST(TestTalkPrivate, GetPermission, filter); +} + +std::string TestTalkPrivate::TestGetPermission() { + if (!talk_private_interface_) { + PASS(); + } + + if (!testing_interface_->IsOutOfProcess()) { + // We only support out-of-process access to this API, so skip in-process + PASS(); + } + +#if defined(USE_ASH) + // Under Ash, this will prompt the user so the test cannot run in an automated + // fashion. To manually test under Ash, comment this out. + PASS(); +#endif + + PP_Resource talk_resource = talk_private_interface_->Create( + instance_->pp_instance()); + + TestCompletionCallback callback(instance_->pp_instance(), callback_type()); + callback.WaitForResult(talk_private_interface_->GetPermission(talk_resource, + callback.GetCallback().pp_completion_callback())); + CHECK_CALLBACK_BEHAVIOR(callback); + +#if defined(USE_ASH) + // Under Ash, this test will actually prompt the user and return either true + // or false depending on their choice. + if (callback.result() != 0 && callback.result() != 1) + return "Unexpected result"; +#else + // Currently not implemented without Ash, bur always returns false. + if (callback.result() != 0) + return "Unexpected non-zero result"; +#endif + + PASS(); +} diff --git a/ppapi/tests/test_talk_private.h b/ppapi/tests/test_talk_private.h new file mode 100644 index 0000000..223f202 --- /dev/null +++ b/ppapi/tests/test_talk_private.h @@ -0,0 +1,27 @@ +// 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. + +#ifndef PAPPI_TESTS_TEST_TALK_PRIVATE_H_ +#define PAPPI_TESTS_TEST_TALK_PRIVATE_H_ + +#include <string> + +#include "ppapi/c/private/ppb_talk_private.h" +#include "ppapi/tests/test_case.h" + +class TestTalkPrivate : public TestCase { + public: + explicit TestTalkPrivate(TestingInstance* instance); + + // TestCase implementation. + virtual bool Init(); + virtual void RunTests(const std::string& filter); + + private: + std::string TestGetPermission(); + + const PPB_Talk_Private* talk_private_interface_; +}; + +#endif // PPAPI_TESTS_TEST_TALK_PRIVATE_H_ |