summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/test/ui/ppapi_uitest.cc29
-rw-r--r--ppapi/ppapi_sources.gypi3
-rw-r--r--ppapi/tests/test_tcp_socket_private_disallowed.cc37
-rw-r--r--ppapi/tests/test_tcp_socket_private_disallowed.h27
-rw-r--r--ppapi/tests/test_udp_socket_private_disallowed.cc37
-rw-r--r--ppapi/tests/test_udp_socket_private_disallowed.h27
6 files changed, 160 insertions, 0 deletions
diff --git a/chrome/test/ui/ppapi_uitest.cc b/chrome/test/ui/ppapi_uitest.cc
index e318098..2f5618ff 100644
--- a/chrome/test/ui/ppapi_uitest.cc
+++ b/chrome/test/ui/ppapi_uitest.cc
@@ -225,6 +225,25 @@ class PPAPINaClTest : public PPAPITestBase {
}
};
+class PPAPINaClTestDisallowedSockets : public PPAPITestBase {
+ public:
+ PPAPINaClTestDisallowedSockets() {
+ FilePath plugin_lib;
+ EXPECT_TRUE(PathService::Get(chrome::FILE_NACL_PLUGIN, &plugin_lib));
+ EXPECT_TRUE(file_util::PathExists(plugin_lib));
+
+ // Enable running NaCl outside of the store.
+ launch_arguments_.AppendSwitch(switches::kEnableNaCl);
+ }
+
+ // Append the correct mode and testcase string
+ std::string BuildQuery(const std::string& base,
+ const std::string& test_case) {
+ return StringPrintf("%smode=nacl&testcase=%s", base.c_str(),
+ test_case.c_str());
+ }
+};
+
// This macro finesses macro expansion to do what we want.
#define STRIP_PREFIXES(test_name) StripPrefixes(#test_name)
@@ -262,6 +281,7 @@ class PPAPINaClTest : public PPAPITestBase {
#if defined(DISABLE_NACL)
#define TEST_PPAPI_NACL_VIA_HTTP(test_name)
+#define TEST_PPAPI_NACL_VIA_HTTP_DISALLOWED_SOCKETS(test_name)
#else
// NaCl based PPAPI tests
@@ -269,6 +289,12 @@ class PPAPINaClTest : public PPAPITestBase {
TEST_F(PPAPINaClTest, test_name) { \
RunTestViaHTTP(STRIP_PREFIXES(test_name)); \
}
+
+// NaCl based PPAPI tests with disallowed socket API
+#define TEST_PPAPI_NACL_VIA_HTTP_DISALLOWED_SOCKETS(test_name) \
+ TEST_F(PPAPINaClTestDisallowedSockets, test_name) { \
+ RunTestViaHTTP(STRIP_PREFIXES(test_name)); \
+}
#endif
@@ -333,6 +359,9 @@ TEST_PPAPI_IN_PROCESS_VIA_HTTP(UDPSocketPrivateShared)
TEST_PPAPI_OUT_OF_PROCESS_VIA_HTTP(UDPSocketPrivateShared)
TEST_PPAPI_NACL_VIA_HTTP(UDPSocketPrivateShared)
+TEST_PPAPI_NACL_VIA_HTTP_DISALLOWED_SOCKETS(TCPSocketPrivateDisallowed)
+TEST_PPAPI_NACL_VIA_HTTP_DISALLOWED_SOCKETS(UDPSocketPrivateDisallowed)
+
// URLLoader tests.
TEST_PPAPI_IN_PROCESS_VIA_HTTP(URLLoader_BasicGET)
TEST_PPAPI_IN_PROCESS_VIA_HTTP(URLLoader_BasicPOST)
diff --git a/ppapi/ppapi_sources.gypi b/ppapi/ppapi_sources.gypi
index 5ebe710..f68c7f9 100644
--- a/ppapi/ppapi_sources.gypi
+++ b/ppapi/ppapi_sources.gypi
@@ -290,9 +290,12 @@
'tests/test_memory.cc',
'tests/test_graphics_2d.cc',
'tests/test_image_data.cc',
+ 'tests/test_memory.cc',
'tests/test_paint_aggregator.cc',
'tests/test_post_message.cc',
'tests/test_scrollbar.cc',
+ 'tests/test_tcp_socket_private_disallowed.cc',
+ 'tests/test_udp_socket_private_disallowed.cc',
'tests/test_url_loader.cc',
'tests/test_var.cc',
],
diff --git a/ppapi/tests/test_tcp_socket_private_disallowed.cc b/ppapi/tests/test_tcp_socket_private_disallowed.cc
new file mode 100644
index 0000000..1193292
--- /dev/null
+++ b/ppapi/tests/test_tcp_socket_private_disallowed.cc
@@ -0,0 +1,37 @@
+// Copyright (c) 2011 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_tcp_socket_private_disallowed.h"
+
+#include "ppapi/cpp/module.h"
+#include "ppapi/tests/testing_instance.h"
+
+REGISTER_TEST_CASE(TCPSocketPrivateDisallowed);
+
+TestTCPSocketPrivateDisallowed::TestTCPSocketPrivateDisallowed(
+ TestingInstance* instance)
+ : TestCase(instance), tcp_socket_private_interface_(NULL) {
+}
+
+bool TestTCPSocketPrivateDisallowed::Init() {
+ tcp_socket_private_interface_ = static_cast<const PPB_TCPSocket_Private*>(
+ pp::Module::Get()->GetBrowserInterface(PPB_TCPSOCKET_PRIVATE_INTERFACE));
+ if (!tcp_socket_private_interface_)
+ instance_->AppendError("TCPSocketPrivate interface not available");
+ return tcp_socket_private_interface_ && CheckTestingInterface();
+}
+
+void TestTCPSocketPrivateDisallowed::RunTests(const std::string& filter) {
+ RUN_TEST(Create, filter);
+}
+
+std::string TestTCPSocketPrivateDisallowed::TestCreate() {
+ PP_Resource socket =
+ tcp_socket_private_interface_->Create(instance_->pp_instance());
+ if (0 != socket) {
+ return "PPB_TCPSocket_Private::Create returns valid socket " \
+ "without allowing switch";
+ }
+ PASS();
+}
diff --git a/ppapi/tests/test_tcp_socket_private_disallowed.h b/ppapi/tests/test_tcp_socket_private_disallowed.h
new file mode 100644
index 0000000..9371028
--- /dev/null
+++ b/ppapi/tests/test_tcp_socket_private_disallowed.h
@@ -0,0 +1,27 @@
+// Copyright (c) 2011 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 PPAPI_TESTS_TEST_TCP_SOCKET_PRIVATE_DISALLOWED_H_
+#define PPAPI_TESTS_TEST_TCP_SOCKET_PRIVATE_DISALLOWED_H_
+
+#include <string>
+
+#include "ppapi/cpp/private/tcp_socket_private.h"
+#include "ppapi/tests/test_case.h"
+
+class TestTCPSocketPrivateDisallowed : public TestCase {
+ public:
+ explicit TestTCPSocketPrivateDisallowed(TestingInstance* instance);
+
+ // TestCase implementation.
+ virtual bool Init();
+ virtual void RunTests(const std::string& filter);
+
+ private:
+ std::string TestCreate();
+
+ const PPB_TCPSocket_Private* tcp_socket_private_interface_;
+};
+
+#endif // PPAPI_TESTS_TEST_TCP_SOCKET_PRIVATE_DISALLOWED_H_
diff --git a/ppapi/tests/test_udp_socket_private_disallowed.cc b/ppapi/tests/test_udp_socket_private_disallowed.cc
new file mode 100644
index 0000000..261fbe8
--- /dev/null
+++ b/ppapi/tests/test_udp_socket_private_disallowed.cc
@@ -0,0 +1,37 @@
+// Copyright (c) 2011 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_udp_socket_private_disallowed.h"
+
+#include "ppapi/cpp/module.h"
+#include "ppapi/tests/testing_instance.h"
+
+REGISTER_TEST_CASE(UDPSocketPrivateDisallowed);
+
+TestUDPSocketPrivateDisallowed::TestUDPSocketPrivateDisallowed(
+ TestingInstance* instance)
+ : TestCase(instance), udp_socket_private_interface_(NULL) {
+}
+
+bool TestUDPSocketPrivateDisallowed::Init() {
+ udp_socket_private_interface_ = static_cast<const PPB_UDPSocket_Private*>(
+ pp::Module::Get()->GetBrowserInterface(PPB_UDPSOCKET_PRIVATE_INTERFACE));
+ if (!udp_socket_private_interface_)
+ instance_->AppendError("UDPSocketPrivate interface not available");
+ return udp_socket_private_interface_ && CheckTestingInterface();
+}
+
+void TestUDPSocketPrivateDisallowed::RunTests(const std::string& filter) {
+ RUN_TEST(Create, filter);
+}
+
+std::string TestUDPSocketPrivateDisallowed::TestCreate() {
+ PP_Resource socket =
+ udp_socket_private_interface_->Create(instance_->pp_instance());
+ if (0 != socket) {
+ return "PPB_UDPSocket_Private::Create returns valid socket " \
+ "without allowing switch";
+ }
+ PASS();
+}
diff --git a/ppapi/tests/test_udp_socket_private_disallowed.h b/ppapi/tests/test_udp_socket_private_disallowed.h
new file mode 100644
index 0000000..807cc9b
--- /dev/null
+++ b/ppapi/tests/test_udp_socket_private_disallowed.h
@@ -0,0 +1,27 @@
+// Copyright (c) 2011 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 PPAPI_TESTS_TEST_UDP_SOCKET_PRIVATE_DISALLOWED_H_
+#define PPAPI_TESTS_TEST_UDP_SOCKET_PRIVATE_DISALLOWED_H_
+
+#include <string>
+
+#include "ppapi/cpp/private/udp_socket_private.h"
+#include "ppapi/tests/test_case.h"
+
+class TestUDPSocketPrivateDisallowed : public TestCase {
+ public:
+ explicit TestUDPSocketPrivateDisallowed(TestingInstance* instance);
+
+ // TestCase implementation.
+ virtual bool Init();
+ virtual void RunTests(const std::string& filter);
+
+ private:
+ std::string TestCreate();
+
+ const PPB_UDPSocket_Private* udp_socket_private_interface_;
+};
+
+#endif // PPAPI_TESTS_TEST_UDP_SOCKET_PRIVATE_DISALLOWED_H_