diff options
author | ncbray@chromium.org <ncbray@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-12 12:44:39 +0000 |
---|---|---|
committer | ncbray@chromium.org <ncbray@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-12 12:44:39 +0000 |
commit | b2ed5b8c002e72cc1e01678282771f1cc8429069 (patch) | |
tree | 3c08807005a7f8b814eb84a199c3bfa2ac80a366 /ppapi/native_client | |
parent | 836fdded75cd34faf2c80d537dba37c269a3a979 (diff) | |
download | chromium_src-b2ed5b8c002e72cc1e01678282771f1cc8429069.zip chromium_src-b2ed5b8c002e72cc1e01678282771f1cc8429069.tar.gz chromium_src-b2ed5b8c002e72cc1e01678282771f1cc8429069.tar.bz2 |
Port PPAPI instance tests from nacl_integration to browser_tests.
BUG=154400
Review URL: https://codereview.chromium.org/113163005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@240287 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/native_client')
8 files changed, 0 insertions, 428 deletions
diff --git a/ppapi/native_client/chrome_main.scons b/ppapi/native_client/chrome_main.scons index eef13dc..6e86f01 100644 --- a/ppapi/native_client/chrome_main.scons +++ b/ppapi/native_client/chrome_main.scons @@ -43,8 +43,6 @@ ppapi_scons_files['nonvariant_test_scons_files'] = [ 'tests/ppapi_browser/crash/nacl.scons', 'tests/ppapi_browser/extension_mime_handler/nacl.scons', 'tests/ppapi_browser/manifest/nacl.scons', - 'tests/ppapi_browser/ppb_instance/nacl.scons', - 'tests/ppapi_browser/ppp_instance/nacl.scons', 'tests/ppapi_test_lib/nacl.scons', ] diff --git a/ppapi/native_client/tests/ppapi_browser/ppb_instance/nacl.scons b/ppapi/native_client/tests/ppapi_browser/ppb_instance/nacl.scons deleted file mode 100644 index 8e44a0a..0000000 --- a/ppapi/native_client/tests/ppapi_browser/ppb_instance/nacl.scons +++ /dev/null @@ -1,38 +0,0 @@ -# -*- python -*- -# Copyright (c) 2012 The Native Client Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. -# -# This test uses ppapi_test_lib. - -Import('env') - -env.Prepend(CPPDEFINES=['XP_UNIX']) -env.Replace(TEST_DIR='${SOURCE_ROOT}/ppapi/native_client/tests/ppapi_browser/' + - 'ppb_instance') - -nexe = env.ProgramNameForNmf('ppapi_ppb_instance') -env.Alias('ppapi_ppb_instance${PROGSUFFIX}', ['$STAGING_DIR/%s${PROGSUFFIX}' % nexe]) - -env.ComponentProgram( - nexe, - ['ppapi_ppb_instance.cc'], - EXTRA_LIBS=['ppapi', - 'ppapi_test_lib', - 'pthread', - 'platform', - 'gio']) - -# Note that the html is required to run this program. -env.Publish(nexe, 'run', - ['ppapi_ppb_instance.html']) - -node = env.PPAPIBrowserTester('ppapi_ppb_instance_browser_test.out', - url='ppapi_ppb_instance.html', - nmf_names=['ppapi_ppb_instance'], - files=env.ExtractPublishedFiles(nexe)) - -env.AddNodeToTestSuite(node, - ['chrome_browser_tests'], - 'run_ppapi_ppb_instance_browser_test', - is_broken=env.PPAPIBrowserTesterIsBroken()) diff --git a/ppapi/native_client/tests/ppapi_browser/ppb_instance/ppapi_ppb_instance.cc b/ppapi/native_client/tests/ppapi_browser/ppb_instance/ppapi_ppb_instance.cc deleted file mode 100644 index 3cafd28..0000000 --- a/ppapi/native_client/tests/ppapi_browser/ppb_instance/ppapi_ppb_instance.cc +++ /dev/null @@ -1,82 +0,0 @@ -// 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 "native_client/src/shared/platform/nacl_check.h" - -#include "ppapi/c/pp_size.h" -#include "ppapi/c/ppb_image_data.h" -#include "ppapi/c/ppb_instance.h" -#include "ppapi/c/ppb_graphics_2d.h" - -#include "ppapi/native_client/tests/ppapi_test_lib/get_browser_interface.h" -#include "ppapi/native_client/tests/ppapi_test_lib/test_interface.h" - -namespace { - - -// Tests PPB_Instance::IsFullFrame(). -void TestIsFullFrame() { - // Note: IsFullFrame returning PP_TRUE is only possible when a plugin - // is a content handler. For coverage, see: - // tests/ppapi_browser/extension_mime_handler/ - PP_Bool full_frame = PPBInstance()->IsFullFrame(pp_instance()); - EXPECT(full_frame == PP_FALSE); - - full_frame = PPBInstance()->IsFullFrame(kInvalidInstance); - EXPECT(full_frame == PP_FALSE); - - TEST_PASSED; -} - -void TestBindGraphics() { - PP_Size size = PP_MakeSize(100, 100); - - PP_Resource graphics1 = PPBGraphics2D()->Create( - pp_instance(), &size, PP_TRUE); - PP_Resource graphics2 = PPBGraphics2D()->Create( - pp_instance(), &size, PP_TRUE); - - EXPECT(graphics1 != kInvalidResource); - EXPECT(graphics2 != kInvalidResource); - - PP_Bool ret = PPBInstance()->BindGraphics(pp_instance(), graphics1); - EXPECT(ret == PP_TRUE); - - // We should be allowed to replace one device with another. - ret = PPBInstance()->BindGraphics(pp_instance(), graphics2); - EXPECT(ret == PP_TRUE); - - // This should fail because instance is not valid. - ret = PPBInstance()->BindGraphics(kInvalidInstance, graphics1); - EXPECT(ret == PP_FALSE); - - // This should fail because instance is not valid and graphics2 is bound. - ret = PPBInstance()->BindGraphics(kInvalidInstance, graphics2); - EXPECT(ret == PP_FALSE); - - // This is not a failure, binding resource 0 simply unbinds all devices. - ret = PPBInstance()->BindGraphics(pp_instance(), kInvalidResource); - EXPECT(ret == PP_TRUE); - - PP_Resource image_data = PPBImageData()->Create( - pp_instance(), PP_IMAGEDATAFORMAT_RGBA_PREMUL, &size, PP_FALSE); - EXPECT(image_data != kInvalidResource); - - // This should fail because the resource is the wrong type. - ret = PPBInstance()->BindGraphics(pp_instance(), image_data); - EXPECT(ret == PP_FALSE); - - TEST_PASSED; -} - -} // namespace - -void SetupTests() { - RegisterTest("TestIsFullFrame", TestIsFullFrame); - RegisterTest("TestBindGraphics", TestBindGraphics); -} - -void SetupPluginInterfaces() { - // none -} diff --git a/ppapi/native_client/tests/ppapi_browser/ppb_instance/ppapi_ppb_instance.html b/ppapi/native_client/tests/ppapi_browser/ppb_instance/ppapi_ppb_instance.html deleted file mode 100644 index d39d0449..0000000 --- a/ppapi/native_client/tests/ppapi_browser/ppb_instance/ppapi_ppb_instance.html +++ /dev/null @@ -1,63 +0,0 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -<html> - <!-- Copyright 2011 Google Inc. All rights reserved. --> - <head> - <META HTTP-EQUIV="Pragma" CONTENT="no-cache" /> - <META HTTP-EQUIV="Expires" CONTENT="-1" /> - <script type="text/javascript" src="nacltest.js"></script> - <script type="application/x-javascript"> - //<![CDATA[ - function setupTests(tester, plugin) { - // This function takes an array of messages and asserts that the nexe - // calls PostMessage with each of these messages, in order. - function expectMessages(test, plugin, messages) { - test.assert(messages.length > 0, 'Must provide at least one message'); - var listener = test.wrap(function(message) { - plugin.removeEventListener('message', listener, false); - test.assertEqual(message.data, messages.shift()); - if (messages.length == 0) { - test.pass(); - } else { - plugin.addEventListener('message', listener, false); - } - }); - plugin.addEventListener('message', listener, false); - } - - function addTest(test_name, responses) { - if (responses === undefined) { - responses = []; - } - var expected_messages = [test_name + ':PASSED'].concat(responses); - tester.addAsyncTest('PPB_Instance::' + test_name, function(test) { - expectMessages(test, plugin, expected_messages); - plugin.postMessage(test_name) - }); - } - - addTest('TestIsFullFrame'); - addTest('TestBindGraphics'); - } - //]]> - </script> - <title>PPAPI PPB_Instance Test</title> - </head> - <body> - <h1>PPAPI PPB_Instance Test</h1> - - <embed type="application/x-nacl" id="test_nexe" - name="nacl_module" - src="ppapi_ppb_instance.nmf" - width="0" height="0" /> - - <script type="text/javascript"> - //<![CDATA[ - var tester = new Tester(); - setupTests(tester, $('test_nexe')); - tester.waitFor($('test_nexe')); - tester.run(); - //]]> - </script> - </body> -</html> diff --git a/ppapi/native_client/tests/ppapi_browser/ppp_instance/nacl.scons b/ppapi/native_client/tests/ppapi_browser/ppp_instance/nacl.scons deleted file mode 100644 index 69d92f1..0000000 --- a/ppapi/native_client/tests/ppapi_browser/ppp_instance/nacl.scons +++ /dev/null @@ -1,40 +0,0 @@ -# -*- python -*- -# Copyright (c) 2012 The Native Client Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. -# -# This test uses ppapi_test_lib. - -Import('env') - -env.Prepend(CPPDEFINES=['XP_UNIX']) -env.Replace(TEST_DIR='${SOURCE_ROOT}/ppapi/native_client/tests/ppapi_browser/' + - 'ppp_instance') - -nexe = env.ProgramNameForNmf('ppapi_ppp_instance') -env.Alias('ppapi_ppp_instance${PROGSUFFIX}', - ['$STAGING_DIR/%s${PROGSUFFIX}' % nexe]) - -ppapi_ppp_instance_nexe = env.ComponentProgram( - nexe, - ['ppapi_ppp_instance.cc'], - EXTRA_LIBS=['ppapi', - 'ppapi_test_lib', - 'platform', # for CHECK - 'pthread', - 'gio', - ]) - -env.Publish(nexe, 'run', - ['ppapi_ppp_instance.html', - 'ppapi_ppp_instance.js']) - -node = env.PPAPIBrowserTester('ppapi_ppp_instance_browser_test.out', - url='ppapi_ppp_instance.html', - nmf_names=['ppapi_ppp_instance'], - files=env.ExtractPublishedFiles(nexe)) - -env.AddNodeToTestSuite(node, - ['chrome_browser_tests'], - 'run_ppapi_ppp_instance_browser_test', - is_broken=env.PPAPIBrowserTesterIsBroken()) diff --git a/ppapi/native_client/tests/ppapi_browser/ppp_instance/ppapi_ppp_instance.cc b/ppapi/native_client/tests/ppapi_browser/ppp_instance/ppapi_ppp_instance.cc deleted file mode 100644 index 0313aad..0000000 --- a/ppapi/native_client/tests/ppapi_browser/ppp_instance/ppapi_ppp_instance.cc +++ /dev/null @@ -1,97 +0,0 @@ -// 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 <string.h> - -#include <vector> - -#include "native_client/src/include/nacl_macros.h" -#include "native_client/src/shared/platform/nacl_check.h" - -#include "ppapi/c/pp_bool.h" -#include "ppapi/c/pp_errors.h" -#include "ppapi/c/pp_input_event.h" -#include "ppapi/c/ppb_view.h" -#include "ppapi/c/ppp_instance.h" - -#include "ppapi/native_client/tests/ppapi_test_lib/get_browser_interface.h" -#include "ppapi/native_client/tests/ppapi_test_lib/test_interface.h" - -namespace { - -PP_Bool DidCreate(PP_Instance instance, - uint32_t argc, - const char* argn[], - const char* argv[]) { - printf("--- PPP_Instance::DidCreate\n"); - PP_Bool status = DidCreateDefault(instance, argc, argn, argv); - // TEST_PASSED has no effect from this function. - // But as long as the plugin loads and tests are run, we know this succeeded. - // See ppapi_browser/bad for failing DidCreate. - return status; -} - -// This should never be called. -void DidDestroy(PP_Instance instance) { - printf("--- PPP_Instance::DidDestroy\n"); - CHECK(instance == pp_instance()); - NACL_NOTREACHED(); -} - -void DidChangeView(PP_Instance instance, PP_Resource view) { - printf("--- PPP_Instance::DidChangeView\n"); - EXPECT(instance == pp_instance()); - - PP_Rect clip; - PPBView()->GetClipRect(view, &clip); - EXPECT(clip.point.x == 0 && clip.point.y == 0); - - // These are based on embed dimensions. - PP_Rect position; - PPBView()->GetRect(view, &position); - EXPECT(position.size.width == 15 && clip.size.width == 15); - EXPECT(position.size.height == 20 && clip.size.height == 20); - - TEST_PASSED; -} - -void DidChangeFocus(PP_Instance instance, - PP_Bool has_focus) { - printf("--- PPP_Instance::DidChangeFocus has_focus=%d\n", has_focus); - // There should be no focus on load, so this will trigger when we gain it - // and then release it and so on. - static bool expected_has_focus = true; - EXPECT(instance == pp_instance()); - EXPECT(has_focus == expected_has_focus); - expected_has_focus = !expected_has_focus; - - TEST_PASSED; -} - -PP_Bool HandleDocumentLoad(PP_Instance instance, - PP_Resource url_loader) { - // Only called for full-frame plugins. For coverage see: - // tests/ppapi_browser/extension_mime_handler/ - NACL_NOTREACHED(); - return PP_FALSE; -} - -const PPP_Instance ppp_instance_interface = { - DidCreate, - DidDestroy, - DidChangeView, - DidChangeFocus, - HandleDocumentLoad -}; - -} // namespace - - -void SetupTests() { - // Each PPP_Instance function called by the browser acts as a test. -} - -void SetupPluginInterfaces() { - RegisterPluginInterface(PPP_INSTANCE_INTERFACE, &ppp_instance_interface); -} diff --git a/ppapi/native_client/tests/ppapi_browser/ppp_instance/ppapi_ppp_instance.html b/ppapi/native_client/tests/ppapi_browser/ppp_instance/ppapi_ppp_instance.html deleted file mode 100644 index ab86fd0..0000000 --- a/ppapi/native_client/tests/ppapi_browser/ppp_instance/ppapi_ppp_instance.html +++ /dev/null @@ -1,34 +0,0 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -<html> - <!-- Copyright (c) 2011 Google Inc. All rights reserved. --> - <head> - <meta http-equiv="Pragma" content="no-cache" /> - <meta http-equiv="Expires" content="-1" /> - <script type="text/javascript" src="nacltest.js"></script> - <script type="text/javascript" src="ppapi_ppp_instance.js"></script> - <title>PPAPI PPP_Instance Test</title> - </head> - <body> - <h1>PPAPI PPP_Instance Test</h1> - - <div id="test_nexe_parent"> - <embed type="application/x-nacl" id="test_nexe" - name="nacl_module" - src="ppapi_ppp_instance.nmf" - style="background-color:#AAAAAA" - width="20" height="20" /> - <!-- NOTE: The width and height must be different from the values checked - in PPP_Instance::DidChangeView so when we set them, they change --> - </div> - <br> - <script type="text/javascript"> - //<![CDATA[ - var tester = new Tester(); - setupTests(tester, $('test_nexe')); - tester.waitFor($('test_nexe')); - tester.run(); - //]]> - </script> - </body> -</html> diff --git a/ppapi/native_client/tests/ppapi_browser/ppp_instance/ppapi_ppp_instance.js b/ppapi/native_client/tests/ppapi_browser/ppp_instance/ppapi_ppp_instance.js deleted file mode 100644 index 8d62b3c..0000000 --- a/ppapi/native_client/tests/ppapi_browser/ppp_instance/ppapi_ppp_instance.js +++ /dev/null @@ -1,72 +0,0 @@ -// 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. - -function startsWith(str, prefix) { - return (str.indexOf(prefix) === 0); -} - -function setupTests(tester, plugin) { - ////////////////////////////////////////////////////////////////////////////// - // Test Helpers - ////////////////////////////////////////////////////////////////////////////// - var numMessages = 0; - function addTestListeners(numListeners, test, testFunction, runCheck) { - var messageListener = test.wrap(function(message) { - if (!startsWith(message.data, testFunction)) return; - test.log(message.data); - numMessages++; - plugin.removeEventListener('message', messageListener, false); - test.assertEqual(message.data, testFunction + ':PASSED'); - if (runCheck) test.assert(runCheck()); - if (numMessages < numListeners) { - plugin.addEventListener('message', messageListener, false); - } else { - numMessages = 0; - test.pass(); - } - }); - plugin.addEventListener('message', messageListener, false); - } - - function addTestListener(test, testFunction, runCheck) { - return addTestListeners(1, test, testFunction, runCheck); - } - - ////////////////////////////////////////////////////////////////////////////// - // Tests - ////////////////////////////////////////////////////////////////////////////// - - tester.addTest('PPP_Instance::DidCreate', function() { - assertEqual(plugin.lastError, ''); - }); - - tester.addAsyncTest('PPP_Instance::DidChangeView', function(test) { - // The .cc file hardcodes an expected 15x20 size. - plugin.width = 15; - plugin.height = 20; - addTestListener(test, 'DidChangeView'); - }); - - tester.addAsyncTest('PPP_Instance::DidChangeFocus', function(test) { - // TODO(polina): How can I simulate focusing on Windows? - // For now just pass explicitely. - if (startsWith(navigator.platform, 'Win')) { - test.log('skipping test on ' + navigator.platform); - test.pass(); - return; - } - addTestListeners(2, test, 'DidChangeFocus'); - plugin.tabIndex = 0; - plugin.focus(); - plugin.blur(); - }); - - // PPP_Instance::HandleDocumentLoad is only used with full-frame plugins. - // This is tested in tests/ppapi_browser/extension_mime_handler/ - - // PPP_Instance::DidDestroy is never invoked in the untrusted code. - // We could wait for a crash event from it, but CallOnMainThread semantics - // on shutdown are still buggy, so it might never come even if the function - // triggered. Plus waiting for something not to happen makes the test flaky. -} |