summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorncbray@google.com <ncbray@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-12 20:29:29 +0000
committerncbray@google.com <ncbray@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-12 20:29:29 +0000
commitcadcf156340055112e738c93925d4aaf228a090c (patch)
treee67d96cd757a3cfcbb7c4b9c65e2f3dc349fcf77
parenteab42ad4a98f554eed0bb54e9a0576f549edc825 (diff)
downloadchromium_src-cadcf156340055112e738c93925d4aaf228a090c.zip
chromium_src-cadcf156340055112e738c93925d4aaf228a090c.tar.gz
chromium_src-cadcf156340055112e738c93925d4aaf228a090c.tar.bz2
Remove redundant PPAPI tests from NaCl SCons build.
BUG= http://code.google.com/p/chromium/issues/detail?id=154400 Review URL: https://codereview.chromium.org/11099015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@161649 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ppapi/native_client/ppapi_scons_files.py4
-rw-r--r--ppapi/native_client/tests/ppapi_browser/ppb_file_io/common.cc183
-rw-r--r--ppapi/native_client/tests/ppapi_browser/ppb_file_io/common.h61
-rw-r--r--ppapi/native_client/tests/ppapi_browser/ppb_file_io/nacl.scons44
-rw-r--r--ppapi/native_client/tests/ppapi_browser/ppb_file_io/ppapi_ppb_file_io.cc40
-rw-r--r--ppapi/native_client/tests/ppapi_browser/ppb_file_io/ppapi_ppb_file_io.html29
-rw-r--r--ppapi/native_client/tests/ppapi_browser/ppb_file_io/ppapi_ppb_file_io.js56
-rw-r--r--ppapi/native_client/tests/ppapi_browser/ppb_file_io/test_open.cc162
-rw-r--r--ppapi/native_client/tests/ppapi_browser/ppb_file_io/test_query.cc76
-rw-r--r--ppapi/native_client/tests/ppapi_browser/ppb_file_io/test_read.cc174
-rw-r--r--ppapi/native_client/tests/ppapi_browser/ppb_file_io/test_sequence_element.cc104
-rw-r--r--ppapi/native_client/tests/ppapi_browser/ppb_file_io/test_sequence_element.h131
-rw-r--r--ppapi/native_client/tests/ppapi_browser/ppb_graphics2d/nacl.scons44
-rw-r--r--ppapi/native_client/tests/ppapi_browser/ppb_graphics2d/ppapi_ppb_graphics2d.cc476
-rw-r--r--ppapi/native_client/tests/ppapi_browser/ppb_graphics2d/ppapi_ppb_graphics2d.html122
-rw-r--r--ppapi/native_client/tests/ppapi_browser/ppb_memory/nacl.scons39
-rw-r--r--ppapi/native_client/tests/ppapi_browser/ppb_memory/ppapi_ppb_memory.cc38
-rw-r--r--ppapi/native_client/tests/ppapi_browser/ppb_memory/ppapi_ppb_memory.html66
-rw-r--r--ppapi/native_client/tests/ppapi_browser/ppb_url_loader/nacl.scons44
-rw-r--r--ppapi/native_client/tests/ppapi_browser/ppb_url_loader/ppapi_ppb_url_loader.cc822
-rw-r--r--ppapi/native_client/tests/ppapi_browser/ppb_url_loader/ppapi_ppb_url_loader.html29
-rw-r--r--ppapi/native_client/tests/ppapi_browser/ppb_url_loader/ppapi_ppb_url_loader.js36
-rw-r--r--ppapi/native_client/tests/ppapi_browser/ppb_url_loader/ppapi_ppb_url_loader.txt1
-rw-r--r--ppapi/native_client/tests/ppapi_geturl/module.cc277
-rw-r--r--ppapi/native_client/tests/ppapi_geturl/module.h62
-rw-r--r--ppapi/native_client/tests/ppapi_geturl/nacl.scons50
-rw-r--r--ppapi/native_client/tests/ppapi_geturl/ppapi_geturl.cc39
-rw-r--r--ppapi/native_client/tests/ppapi_geturl/ppapi_geturl.html102
-rw-r--r--ppapi/native_client/tests/ppapi_geturl/ppapi_geturl_success.html5
-rw-r--r--ppapi/native_client/tests/ppapi_geturl/url_load_request.cc350
-rw-r--r--ppapi/native_client/tests/ppapi_geturl/url_load_request.h79
31 files changed, 0 insertions, 3745 deletions
diff --git a/ppapi/native_client/ppapi_scons_files.py b/ppapi/native_client/ppapi_scons_files.py
index ae1e4b4..42511d79 100644
--- a/ppapi/native_client/ppapi_scons_files.py
+++ b/ppapi/native_client/ppapi_scons_files.py
@@ -29,18 +29,14 @@ nonvariant_test_scons_files = [
'tests/ppapi_browser/ppb_dev/nacl.scons',
'tests/ppapi_browser/ppb_file_system/nacl.scons',
'tests/ppapi_browser/ppb_fullscreen/nacl.scons',
- 'tests/ppapi_browser/ppb_graphics2d/nacl.scons',
'tests/ppapi_browser/ppb_graphics3d/nacl.scons',
'tests/ppapi_browser/ppb_image_data/nacl.scons',
'tests/ppapi_browser/ppb_instance/nacl.scons',
- 'tests/ppapi_browser/ppb_memory/nacl.scons',
- 'tests/ppapi_browser/ppb_url_loader/nacl.scons',
'tests/ppapi_browser/ppb_var/nacl.scons',
'tests/ppapi_browser/ppp_input_event/nacl.scons',
'tests/ppapi_browser/ppp_instance/nacl.scons',
'tests/ppapi_browser/progress_events/nacl.scons',
'tests/ppapi_browser/stress_many_nexes/nacl.scons',
- 'tests/ppapi_geturl/nacl.scons',
'tests/ppapi_messaging/nacl.scons',
'tests/ppapi_test_lib/nacl.scons',
]
diff --git a/ppapi/native_client/tests/ppapi_browser/ppb_file_io/common.cc b/ppapi/native_client/tests/ppapi_browser/ppb_file_io/common.cc
deleted file mode 100644
index 38a7c3a..0000000
--- a/ppapi/native_client/tests/ppapi_browser/ppb_file_io/common.cc
+++ /dev/null
@@ -1,183 +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 "ppapi/native_client/tests/ppapi_browser/ppb_file_io/common.h"
-
-#include <string.h>
-#include <string>
-
-#include "native_client/src/shared/platform/nacl_check.h"
-#include "ppapi/c/pp_errors.h"
-#include "ppapi/c/ppb_core.h"
-#include "ppapi/c/ppb_file_io.h"
-#include "ppapi/c/ppb_file_ref.h"
-#include "ppapi/c/ppb_file_system.h"
-#include "ppapi/c/ppb_messaging.h"
-#include "ppapi/c/ppb_url_loader.h"
-#include "ppapi/c/ppb_var.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 common {
-
-const char* kTestData =
- "Everywhere is within walking distance if you have the time";
-
-void InitFileInfo(PP_FileSystemType system_type, PP_FileInfo* file_info) {
- memset(file_info, 0, sizeof(PP_FileInfo));
- file_info->system_type = system_type;
- file_info->type = PP_FILETYPE_REGULAR;
- file_info->last_access_time = 200; // dummy value
- file_info->last_modified_time = 100; // something less than last access time
-}
-
-BoundPPAPIFunc OpenFileForTest::GetCompletionCallbackInitiatingPPAPIFunction(
- TestCallbackData* callback_data) {
- return std::tr1::bind(PPBFileIO()->Open,
- callback_data->existing_file_io,
- callback_data->existing_file_ref,
- PP_FILEOPENFLAG_READ | PP_FILEOPENFLAG_WRITE,
- std::tr1::placeholders::_1);
-}
-
-void FileIOTester::AddSequenceElement(TestSequenceElement* element) {
- test_sequence_.push_back(element);
-}
-
-void FileIOTester::Run() {
- if (test_sequence_.empty())
- return;
-
- PP_Resource file_system = PPBFileSystem()->Create(pp_instance(),
- file_info_.system_type);
- EXPECT(file_system != kInvalidResource);
-
- TestCallbackData* callback_data = new TestCallbackData(file_system,
- file_info_,
- test_sequence_);
-
- int32_t pp_error = PPBFileSystem()->Open(
- callback_data->file_system,
- 1024,
- MakeTestableCompletionCallback(
- "OpenFileSystemForSetupCallback",
- OpenFileSystemForSetupCallback,
- callback_data));
- EXPECT(pp_error == PP_OK_COMPLETIONPENDING);
-}
-
-void FileIOTester::FlushFileForSetupCallback(void* data, int32_t result) {
- // This callback should be preceded by a write operation.
- EXPECT(result >= PP_OK);
-
- TestCallbackData* callback_data = reinterpret_cast<TestCallbackData*>(data);
- PP_FileInfo file_info = callback_data->file_info;
- int32_t pp_error = PPBFileIO()->Touch(callback_data->existing_file_io,
- file_info.last_access_time,
- file_info.last_modified_time,
- MakeTestableCompletionCallback(
- "TouchFileForSetupCallback",
- TouchFileForSetupCallback,
- callback_data));
- EXPECT(pp_error == PP_OK_COMPLETIONPENDING);
-}
-
-// This is the first callback in the chain of callbacks. The first several in
-// the chain are initialization for the tests that come later in the chain.
-void FileIOTester::OpenFileSystemForSetupCallback(void* data, int32_t result) {
- EXPECT(result == PP_OK);
-
- // Need to retrieve file system from the data in order to create file ref
- TestCallbackData* callback_data = reinterpret_cast<TestCallbackData*>(data);
- const PP_Resource file_system = callback_data->file_system;
- // Create file ref for non-existing file
- callback_data->non_existing_file_ref = PPBFileRef()->Create(
- file_system,
- "/non_existing_file");
- EXPECT(callback_data->non_existing_file_ref != kInvalidResource);
-
- // Create file io for non-existing file
- callback_data->non_existing_file_io = PPBFileIO()->Create(pp_instance());
- EXPECT(callback_data->non_existing_file_io != kInvalidResource);
-
- // Create file ref for existing file
- callback_data->existing_file_ref = PPBFileRef()->Create(file_system,
- "/existing_file");
- EXPECT(callback_data->existing_file_ref != kInvalidResource);
-
- // Create file io for existing file
- callback_data->existing_file_io = PPBFileIO()->Create(pp_instance());
- EXPECT(callback_data->existing_file_io != kInvalidResource);
-
- const PP_FileInfo& file_info = callback_data->file_info;
- if (file_info.type == PP_FILETYPE_REGULAR) {
- int32_t pp_error = PPBFileIO()->Open(callback_data->existing_file_io,
- callback_data->existing_file_ref,
- PP_FILEOPENFLAG_TRUNCATE |
- PP_FILEOPENFLAG_CREATE |
- PP_FILEOPENFLAG_WRITE,
- MakeTestableCompletionCallback(
- "OpenFileForSetupCallback",
- OpenFileForSetupCallback,
- callback_data));
- EXPECT(pp_error == PP_OK_COMPLETIONPENDING);
- } else if (file_info.type == PP_FILETYPE_DIRECTORY) {
- // TODO(sanga): Log a message indicating directories are not yet supported
- // in these tests.
- }
-}
-
-void FileIOTester::OpenFileForSetupCallback(void* data, int32_t result) {
- EXPECT(result == PP_OK);
-
- TestCallbackData* callback_data = reinterpret_cast<TestCallbackData*>(data);
- PP_FileInfo file_info = callback_data->file_info;
- int32_t pp_error = PPBFileIO()->Write(callback_data->existing_file_io,
- 0, // no offset
- kTestData,
- strlen(kTestData),
- MakeTestableCompletionCallback(
- "WriteFileForSetupCallback",
- WriteFileForSetupCallback,
- callback_data));
- EXPECT(pp_error == PP_OK_COMPLETIONPENDING);
-}
-
-void FileIOTester::StartTestSequence(TestCallbackData* callback_data) {
- if (!callback_data->test_sequence.empty()) {
- TestSequenceElement* first_test_element =
- callback_data->test_sequence.front();
- PP_CompletionCallback callback = MakeTestableCompletionCallback(
- first_test_element->name(),
- TestSequenceElement::TestSequenceElementForwardingCallback,
- callback_data);
- PPBCore()->CallOnMainThread(0, // no delay
- callback, PP_OK);
- } else {
- TestSequenceElement::CleanupResources(callback_data);
- }
-}
-
-// Assign testing file properties with data from given callback data.
-void FileIOTester::TouchFileForSetupCallback(void* data, int32_t result) {
- EXPECT(result == PP_OK);
-
- TestCallbackData* callback_data = reinterpret_cast<TestCallbackData*>(data);
- PPBFileIO()->Close(callback_data->existing_file_io);
- StartTestSequence(callback_data);
-}
-
-void FileIOTester::WriteFileForSetupCallback(void* data, int32_t result) {
- EXPECT(result >= PP_OK);
-
- TestCallbackData* callback_data = reinterpret_cast<TestCallbackData*>(data);
- int32_t pp_error = PPBFileIO()->Flush(callback_data->existing_file_io,
- MakeTestableCompletionCallback(
- "FlushFileForSetupCallback",
- FlushFileForSetupCallback,
- callback_data));
- EXPECT(pp_error == PP_OK_COMPLETIONPENDING);
-}
-
-} // namespace common
diff --git a/ppapi/native_client/tests/ppapi_browser/ppb_file_io/common.h b/ppapi/native_client/tests/ppapi_browser/ppb_file_io/common.h
deleted file mode 100644
index eef0cad..0000000
--- a/ppapi/native_client/tests/ppapi_browser/ppb_file_io/common.h
+++ /dev/null
@@ -1,61 +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.
-#ifndef NATIVE_CLIENT_TESTS_PPAPI_BROWSER_PPB_FILE_IO_COMMON_H_
-#define NATIVE_CLIENT_TESTS_PPAPI_BROWSER_PPB_FILE_IO_COMMON_H_
-
-#include <deque>
-
-#include "ppapi/c/pp_file_info.h"
-#include "ppapi/native_client/tests/ppapi_browser/ppb_file_io/test_sequence_element.h"
-#include "ppapi/native_client/tests/ppapi_test_lib/test_interface.h"
-
-namespace common {
-
-extern const char* kTestData;
-
-// Open file for subsequent tests.
-class OpenFileForTest : public TestSequenceElement {
- public:
- OpenFileForTest()
- : TestSequenceElement("OpenFileForTest") {}
-
- private:
- virtual BoundPPAPIFunc GetCompletionCallbackInitiatingPPAPIFunction(
- TestCallbackData* callback_data);
-};
-
-// Initializes the member data of given file info to either known values, (e.g.
-// file system type), or dummy values (e.g. last modified time).
-void InitFileInfo(PP_FileSystemType system_type, PP_FileInfo* file_info);
-
-// TODO(sanga): Move this to file_io_tester.h
-// FileIOTester is the test runner. Used to accrue a sequence of test elements
-// in a specific order and run the sequence.
-class FileIOTester {
- public:
- explicit FileIOTester(const PP_FileInfo& file_info)
- : file_info_(file_info) {}
- ~FileIOTester() {}
-
- void AddSequenceElement(TestSequenceElement* element); // sink
- void Run();
-
- private:
- // Callbacks for setting up before executing the test sequence.
- static void FlushFileForSetupCallback(void* data, int32_t result);
- static void OpenFileForSetupCallback(void* data, int32_t result);
- static void OpenFileSystemForSetupCallback(void* data, int32_t result);
- static void StartTestSequence(TestCallbackData* callback_data);
- static void TouchFileForSetupCallback(void* data, int32_t result);
- static void WriteFileForSetupCallback(void* data, int32_t result);
-
- const PP_FileInfo file_info_;
- std::deque<TestSequenceElement*> test_sequence_;
-
- DISALLOW_COPY_AND_ASSIGN(FileIOTester);
-};
-
-} // namespace common
-
-#endif // NATIVE_CLIENT_TESTS_PPAPI_BROWSER_PPB_FILE_IO_COMMON_H_
diff --git a/ppapi/native_client/tests/ppapi_browser/ppb_file_io/nacl.scons b/ppapi/native_client/tests/ppapi_browser/ppb_file_io/nacl.scons
deleted file mode 100644
index feb642b..0000000
--- a/ppapi/native_client/tests/ppapi_browser/ppb_file_io/nacl.scons
+++ /dev/null
@@ -1,44 +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_file_io')
-
-nexe = env.ProgramNameForNmf('ppapi_ppb_file_io')
-env.Alias('ppapi_ppb_file_io${PROGSUFFIX}',
- ['$STAGING_DIR/%s${PROGSUFFIX}' % nexe])
-
-env.ComponentProgram(nexe,
- ['common.cc',
- 'test_open.cc',
- 'test_read.cc',
- 'test_query.cc',
- 'test_sequence_element.cc',
- 'ppapi_ppb_file_io.cc'],
- EXTRA_LIBS=['ppapi',
- 'ppapi_test_lib',
- 'platform',
- 'pthread',
- 'gio'])
-
-env.Publish(nexe, 'run',
- ['ppapi_ppb_file_io.html',
- 'ppapi_ppb_file_io.js'])
-
-node = env.PPAPIBrowserTester('ppapi_ppb_file_io_browser_test.out',
- url='ppapi_ppb_file_io.html',
- nmf_names=['ppapi_ppb_file_io'],
- browser_flags=['--unlimited-quota-for-files'],
- files=env.ExtractPublishedFiles(nexe))
-
-env.AddNodeToTestSuite(node,
- ['chrome_browser_tests'],
- 'run_ppapi_ppb_file_io_browser_test',
- is_broken=env.PPAPIBrowserTesterIsBroken())
diff --git a/ppapi/native_client/tests/ppapi_browser/ppb_file_io/ppapi_ppb_file_io.cc b/ppapi/native_client/tests/ppapi_browser/ppb_file_io/ppapi_ppb_file_io.cc
deleted file mode 100644
index 08137a5..0000000
--- a/ppapi/native_client/tests/ppapi_browser/ppb_file_io/ppapi_ppb_file_io.cc
+++ /dev/null
@@ -1,40 +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/native_client/tests/ppapi_browser/ppb_file_io/common.h"
-#include "ppapi/native_client/tests/ppapi_test_lib/get_browser_interface.h"
-#include "ppapi/native_client/tests/ppapi_test_lib/test_interface.h"
-
-// Open tests
-extern void TestOpenExistingFileLocalTemporary();
-extern void TestOpenNonExistingFileLocalTemporary();
-// Query tests
-extern void TestQueryFileLocalTemporary();
-// Read tests
-extern void TestCompleteReadLocalTemporary();
-extern void TestParallelReadLocalTemporary();
-extern void TestPartialFileReadLocalTemporary();
-
-void SetupTests() {
- // Open tests
- RegisterTest("TestOpenExistingFileLocalTemporary",
- TestOpenExistingFileLocalTemporary);
- RegisterTest("TestOpenNonExistingFileLocalTemporary",
- TestOpenNonExistingFileLocalTemporary);
- // Query tests
- RegisterTest("TestQueryFileLocalTemporary",
- TestQueryFileLocalTemporary);
- // Read tests
- RegisterTest("TestCompleteReadLocalTemporary",
- TestCompleteReadLocalTemporary);
- RegisterTest("TestParallelReadLocalTemporary",
- TestParallelReadLocalTemporary);
- RegisterTest("TestPartialFileReadLocalTemporary",
- TestPartialFileReadLocalTemporary);
-}
-
-void SetupPluginInterfaces() {
- /* No PPP interface to test. */
-}
diff --git a/ppapi/native_client/tests/ppapi_browser/ppb_file_io/ppapi_ppb_file_io.html b/ppapi/native_client/tests/ppapi_browser/ppb_file_io/ppapi_ppb_file_io.html
deleted file mode 100644
index 77391f6..0000000
--- a/ppapi/native_client/tests/ppapi_browser/ppb_file_io/ppapi_ppb_file_io.html
+++ /dev/null
@@ -1,29 +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="text/javascript" src="ppapi_ppb_file_io.js"></script>
- <title>PPAPI PPB_FileIO Test</title>
- </head>
- <body>
- <h1>PPAPI PPB_FileIO Test</h1>
-
- <embed type="application/x-nacl" id="test_nexe"
- name="nacl_module"
- src="ppapi_ppb_file_io.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/ppb_file_io/ppapi_ppb_file_io.js b/ppapi/native_client/tests/ppapi_browser/ppb_file_io/ppapi_ppb_file_io.js
deleted file mode 100644
index bea7a15..0000000
--- a/ppapi/native_client/tests/ppapi_browser/ppb_file_io/ppapi_ppb_file_io.js
+++ /dev/null
@@ -1,56 +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 setupTests(tester, plugin) {
- function addTest(testName, responses) {
- var expectedMessages = [testName + ':PASSED'];
- if (responses != undefined)
- expectedMessages = expectedMessages.concat(responses);
- tester.addAsyncTest('PPB_FileIO::' + testName, function(test) {
- test.expectMessageSequence(plugin, expectedMessages);
- plugin.postMessage(testName);
- });
- }
- var setupCallbacks = [
- 'OpenFileSystemForSetupCallback',
- 'OpenFileForSetupCallback',
- 'WriteFileForSetupCallback',
- 'FlushFileForSetupCallback',
- 'TouchFileForSetupCallback'];
- addTest('TestOpenExistingFileLocalTemporary',
- setupCallbacks.concat(['TestOpenForRead',
- 'TestOpenForWrite',
- 'TestOpenTruncate',
- 'TestOpenForWriteCreateExclusive',
- 'TestOpenForWriteCreate',
- 'END']));
- addTest('TestOpenNonExistingFileLocalTemporary',
- setupCallbacks.concat(['TestOpenForRead',
- 'TestOpenForWrite',
- 'TestOpenForWriteCreate',
- 'DeleteFile',
- 'TestOpenForWriteCreateExclusive',
- 'END']));
- addTest('TestQueryFileLocalTemporary',
- setupCallbacks.concat(['OpenFileForTest',
- 'TestQuery',
- 'TestQueryFileVerify',
- 'END']));
- addTest('TestPartialFileReadLocalTemporary',
- setupCallbacks.concat(['OpenFileForTest',
- 'TestFileRead',
- 'ReadCallback:VERIFIED',
- 'END']));
- addTest('TestCompleteReadLocalTemporary',
- setupCallbacks.concat(['OpenFileForTest',
- 'TestFileRead',
- 'ReadCallback:VERIFIED',
- 'END']));
- addTest('TestParallelReadLocalTemporary',
- setupCallbacks.concat(['OpenFileForTest',
- 'TestParallelRead',
- 'ReadCallback:VERIFIED',
- 'ReadCallback:VERIFIED',
- 'END']));
-};
diff --git a/ppapi/native_client/tests/ppapi_browser/ppb_file_io/test_open.cc b/ppapi/native_client/tests/ppapi_browser/ppb_file_io/test_open.cc
deleted file mode 100644
index 5d736a5..0000000
--- a/ppapi/native_client/tests/ppapi_browser/ppb_file_io/test_open.cc
+++ /dev/null
@@ -1,162 +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 "ppapi/c/pp_errors.h"
-#include "ppapi/c/ppb_core.h"
-#include "ppapi/c/ppb_file_io.h"
-#include "ppapi/c/ppb_file_ref.h"
-#include "ppapi/c/ppb_file_system.h"
-#include "ppapi/c/ppb_url_loader.h"
-#include "ppapi/native_client/tests/ppapi_browser/ppb_file_io/common.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 {
-
-using common::BoundPPAPIFunc;
-using common::FileIOTester;
-using common::InitFileInfo;
-using common::TestCallbackData;
-using common::TestSequenceElement;
-
-class TestOpenExistingFileSequenceElement : public TestSequenceElement {
- public:
- TestOpenExistingFileSequenceElement(const std::string& name,
- int32_t expected_return_value,
- int32_t expected_result, int32_t flags)
- : TestSequenceElement(name, expected_return_value, expected_result),
- flags_(flags) {}
- virtual ~TestOpenExistingFileSequenceElement() {}
-
- private:
- virtual BoundPPAPIFunc GetCompletionCallbackInitiatingPPAPIFunction(
- TestCallbackData* callback_data) {
- return std::tr1::bind(PPBFileIO()->Open, callback_data->existing_file_io,
- callback_data->existing_file_ref, flags_,
- std::tr1::placeholders::_1);
- }
- virtual void Setup(TestCallbackData* callback_data) {
- // We make sure the file io is closed before each test.
- PPBFileIO()->Close(callback_data->existing_file_io);
- }
-
- const int32_t flags_;
-};
-
-class TestOpenNonExistingFileSequenceElement : public TestSequenceElement {
- public:
- TestOpenNonExistingFileSequenceElement(const std::string& name,
- int32_t expected_return_value,
- int32_t expected_result, int32_t flags)
- : TestSequenceElement(name, expected_return_value, expected_result),
- flags_(flags) {}
- virtual ~TestOpenNonExistingFileSequenceElement() {}
-
- private:
- virtual BoundPPAPIFunc GetCompletionCallbackInitiatingPPAPIFunction(
- TestCallbackData* callback_data) {
- return std::tr1::bind(PPBFileIO()->Open,
- callback_data->non_existing_file_io,
- callback_data->non_existing_file_ref, flags_,
- std::tr1::placeholders::_1);
- }
- virtual void Setup(TestCallbackData* callback_data) {
- // We make sure the file io is closed before each test.
- PPBFileIO()->Close(callback_data->non_existing_file_io);
- }
-
- const int32_t flags_;
-};
-
-class DeleteFile : public TestSequenceElement {
- public:
- DeleteFile()
- : TestSequenceElement("DeleteFile", PP_OK_COMPLETIONPENDING, PP_OK) {}
-
- private:
- virtual BoundPPAPIFunc GetCompletionCallbackInitiatingPPAPIFunction(
- TestCallbackData* callback_data) {
- return std::tr1::bind(PPBFileRef()->Delete,
- callback_data->non_existing_file_ref,
- std::tr1::placeholders::_1);
- }
-};
-
-void TestOpenNonExistingFile(PP_FileSystemType system_type) {
- PP_FileInfo file_info = { 0 };
- InitFileInfo(system_type, &file_info);
-
- FileIOTester tester(file_info);
- tester.AddSequenceElement(
- new TestOpenNonExistingFileSequenceElement("TestOpenForRead",
- PP_OK_COMPLETIONPENDING,
- PP_ERROR_FILENOTFOUND,
- PP_FILEOPENFLAG_READ));
- tester.AddSequenceElement(
- new TestOpenNonExistingFileSequenceElement("TestOpenForWrite",
- PP_OK_COMPLETIONPENDING,
- PP_ERROR_FILENOTFOUND,
- PP_FILEOPENFLAG_WRITE));
- tester.AddSequenceElement(
- new TestOpenNonExistingFileSequenceElement("TestOpenForWriteCreate",
- PP_OK_COMPLETIONPENDING,
- PP_OK,
- PP_FILEOPENFLAG_CREATE |
- PP_FILEOPENFLAG_WRITE));
- tester.AddSequenceElement(new DeleteFile);
- tester.AddSequenceElement(
- new TestOpenNonExistingFileSequenceElement(
- "TestOpenForWriteCreateExclusive",
- PP_OK_COMPLETIONPENDING,
- PP_OK,
- PP_FILEOPENFLAG_WRITE |
- PP_FILEOPENFLAG_CREATE |
- PP_FILEOPENFLAG_EXCLUSIVE));
- tester.Run();
-}
-
-void TestOpenExistingFile(PP_FileSystemType system_type) {
- PP_FileInfo file_info = { 0 };
- InitFileInfo(system_type, &file_info);
-
- FileIOTester tester(file_info);
- tester.AddSequenceElement(
- new TestOpenExistingFileSequenceElement("TestOpenForRead",
- PP_OK_COMPLETIONPENDING, PP_OK,
- PP_FILEOPENFLAG_READ));
- tester.AddSequenceElement(
- new TestOpenExistingFileSequenceElement("TestOpenForWrite",
- PP_OK_COMPLETIONPENDING, PP_OK,
- PP_FILEOPENFLAG_WRITE));
- tester.AddSequenceElement(
- new TestOpenExistingFileSequenceElement("TestOpenTruncate",
- PP_ERROR_BADARGUMENT,
- PP_ERROR_FAILED,
- PP_FILEOPENFLAG_TRUNCATE));
- tester.AddSequenceElement(
- new TestOpenExistingFileSequenceElement("TestOpenForWriteCreateExclusive",
- PP_OK_COMPLETIONPENDING,
- PP_ERROR_FILEEXISTS,
- PP_FILEOPENFLAG_WRITE |
- PP_FILEOPENFLAG_CREATE |
- PP_FILEOPENFLAG_EXCLUSIVE));
- tester.AddSequenceElement(
- new TestOpenExistingFileSequenceElement("TestOpenForWriteCreate",
- PP_OK_COMPLETIONPENDING, PP_OK,
- PP_FILEOPENFLAG_WRITE |
- PP_FILEOPENFLAG_CREATE));
- tester.Run();
-}
-
-} // namespace
-
-void TestOpenExistingFileLocalTemporary() {
- TestOpenExistingFile(PP_FILESYSTEMTYPE_LOCALTEMPORARY);
- TEST_PASSED;
-}
-
-void TestOpenNonExistingFileLocalTemporary() {
- TestOpenNonExistingFile(PP_FILESYSTEMTYPE_LOCALTEMPORARY);
- TEST_PASSED;
-}
diff --git a/ppapi/native_client/tests/ppapi_browser/ppb_file_io/test_query.cc b/ppapi/native_client/tests/ppapi_browser/ppb_file_io/test_query.cc
deleted file mode 100644
index b3d7d08..0000000
--- a/ppapi/native_client/tests/ppapi_browser/ppb_file_io/test_query.cc
+++ /dev/null
@@ -1,76 +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 "ppapi/c/pp_errors.h"
-#include "ppapi/c/ppb_core.h"
-#include "ppapi/c/ppb_file_io.h"
-#include "ppapi/c/ppb_file_ref.h"
-#include "ppapi/c/ppb_file_system.h"
-#include "ppapi/native_client/tests/ppapi_test_lib/get_browser_interface.h"
-#include "ppapi/native_client/tests/ppapi_test_lib/test_interface.h"
-#include "ppapi/native_client/tests/ppapi_browser/ppb_file_io/common.h"
-
-namespace {
-
-using common::BoundPPAPIFunc;
-using common::FileIOTester;
-using common::InitFileInfo;
-using common::kTestData;
-using common::OpenFileForTest;
-using common::TestCallbackData;
-using common::TestSequenceElement;
-
-class TestQuery : public TestSequenceElement {
- public:
- TestQuery() : TestSequenceElement("TestQuery") {}
-
- private:
- virtual BoundPPAPIFunc GetCompletionCallbackInitiatingPPAPIFunction(
- TestCallbackData* callback_data) {
- PP_FileInfo* file_info = new PP_FileInfo;
- callback_data->data = file_info;
- return std::tr1::bind(PPBFileIO()->Query, callback_data->existing_file_io,
- file_info, std::tr1::placeholders::_1);
- }
-};
-
-// Verify the results of calling PPB_FileIO:::Query in from a TestQuery object.
-class TestQueryFileVerify : public TestSequenceElement {
- public:
- TestQueryFileVerify() : TestSequenceElement("TestQueryFileVerify") {}
-
- private:
- virtual void Execute(TestCallbackData* callback_data) {
- PP_FileInfo* file_info =
- reinterpret_cast<PP_FileInfo*>(callback_data->data);
- EXPECT(file_info->type == callback_data->file_info.type);
- EXPECT(file_info->system_type == callback_data->file_info.system_type);
- // TODO(sanga): Fix this with the correct test.
- // EXPECT(file_info->last_access_time ==
- // callback_data->file_info.last_access_time);
- EXPECT(file_info->last_modified_time ==
- callback_data->file_info.last_modified_time);
- EXPECT(file_info->size == strlen(kTestData));
- delete file_info;
- }
-};
-
-void TestQueryFile(PP_FileSystemType system_type) {
- PP_FileInfo file_info = { 0 };
- InitFileInfo(system_type, &file_info);
- FileIOTester tester(file_info);
- tester.AddSequenceElement(new OpenFileForTest);
- tester.AddSequenceElement(new TestQuery);
- tester.AddSequenceElement(new TestQueryFileVerify);
- tester.Run();
-}
-
-} // namespace
-
-void TestQueryFileLocalTemporary() {
- TestQueryFile(PP_FILESYSTEMTYPE_LOCALTEMPORARY);
- TEST_PASSED;
-}
diff --git a/ppapi/native_client/tests/ppapi_browser/ppb_file_io/test_read.cc b/ppapi/native_client/tests/ppapi_browser/ppb_file_io/test_read.cc
deleted file mode 100644
index 713a461..0000000
--- a/ppapi/native_client/tests/ppapi_browser/ppb_file_io/test_read.cc
+++ /dev/null
@@ -1,174 +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 "native_client/src/shared/platform/nacl_check.h"
-#include "ppapi/c/pp_errors.h"
-#include "ppapi/c/ppb_file_io.h"
-#include "ppapi/native_client/tests/ppapi_test_lib/get_browser_interface.h"
-#include "ppapi/native_client/tests/ppapi_test_lib/test_interface.h"
-#include "ppapi/native_client/tests/ppapi_browser/ppb_file_io/common.h"
-
-namespace {
-
-using common::FileIOTester;
-using common::InitFileInfo;
-using common::kTestData;
-using common::OpenFileForTest;
-using common::TestCallbackData;
-using common::TestSequenceElement;
-
-struct TestReadData {
- TestReadData(PP_Resource file_io, int64_t offset_bytes, int32_t bytes_to_read)
- : file_io(file_io), buffer(new char[bytes_to_read]),
- offset(offset_bytes), bytes_to_read(bytes_to_read), bytes_read(0) { }
- ~TestReadData() {
- delete[] buffer;
- }
-
- const PP_Resource file_io;
- char* const buffer;
- const int64_t offset;
- const int32_t bytes_to_read;
- int32_t bytes_read;
-};
-
-// Completion callback function called from the read operation. If the read
-// operation is not completed, a successive read operation will be invoked.
-void ReadCallback(void* data, int32_t bytes_read) {
- EXPECT(bytes_read >= 0);
-
- TestReadData* read_data = reinterpret_cast<TestReadData*>(data);
- read_data->bytes_read += bytes_read;
-
- if (read_data->bytes_read == read_data->bytes_to_read ||
- bytes_read == 0) { // no more bytes to available to read
- // Verify the data
- EXPECT(strncmp(kTestData + read_data->offset, read_data->buffer,
- read_data->bytes_read) == 0);
- PostTestMessage(__FUNCTION__, "VERIFIED"); // Test for this in browser.
- delete read_data;
- } else {
- int64_t offset = read_data->offset + read_data->bytes_read;
- char* buffer = read_data->buffer + read_data->bytes_read;
- int32_t bytes_to_read =
- read_data->bytes_to_read - read_data->bytes_read;
- PPBFileIO()->Read(read_data->file_io, offset, buffer, bytes_to_read,
- PP_MakeCompletionCallback(ReadCallback, read_data));
- }
-}
-
-// TestParallelRead performs two read operations, one from the beginning of the
-// file, and one from the offset. Both operations are of the same size.
-class TestParallelRead : public TestSequenceElement {
- public:
- TestParallelRead(int64_t offset, int32_t bytes_to_read)
- : TestSequenceElement("TestParallelRead", PP_OK_COMPLETIONPENDING, PP_OK),
- offset_(offset), bytes_to_read_(bytes_to_read) {}
-
- private:
- virtual void Setup(TestCallbackData* callback_data) {
- TestReadData* read_data = new TestReadData(callback_data->existing_file_io,
- 0, // read from beginning
- bytes_to_read_);
- int32_t pp_error = PPBFileIO()->Read(read_data->file_io, read_data->offset,
- read_data->buffer,
- read_data->bytes_to_read,
- PP_MakeCompletionCallback(ReadCallback,
- read_data));
- EXPECT(pp_error == PP_OK_COMPLETIONPENDING);
-
- read_data = new TestReadData(callback_data->existing_file_io, offset_,
- bytes_to_read_);
- pp_error = PPBFileIO()->Read(read_data->file_io, read_data->offset,
- read_data->buffer,
- read_data->bytes_to_read,
- PP_MakeCompletionCallback(ReadCallback,
- read_data));
- EXPECT(pp_error == PP_OK_COMPLETIONPENDING);
- }
-
- const int32_t offset_;
- const int32_t bytes_to_read_;
-};
-
-class TestFileRead : public TestSequenceElement {
- public:
- TestFileRead(int64_t offset, int32_t bytes_to_read)
- : TestSequenceElement("TestFileRead", PP_OK_COMPLETIONPENDING, PP_OK),
- offset_(offset), bytes_to_read_(bytes_to_read) {}
-
- private:
- void Setup(TestCallbackData* callback_data) {
- TestReadData* read_data = new TestReadData(callback_data->existing_file_io,
- offset_, bytes_to_read_);
- int32_t pp_error = PPBFileIO()->Read(read_data->file_io, read_data->offset,
- read_data->buffer,
- read_data->bytes_to_read,
- PP_MakeCompletionCallback(ReadCallback,
- read_data));
- EXPECT(pp_error == PP_OK_COMPLETIONPENDING);
- }
-
- const int64_t offset_;
- const int32_t bytes_to_read_;
-};
-
-// Test the partial read of a file
-void TestPartialFileRead(PP_FileSystemType system_type) {
- PP_FileInfo file_info = { 0 };
- InitFileInfo(system_type, &file_info);
-
- const int64_t offset = 1; // some non-zero offset
- const int32_t bytes_to_read = strlen(kTestData) / 2;
-
- FileIOTester tester(file_info);
- tester.AddSequenceElement(new OpenFileForTest);
- tester.AddSequenceElement(new TestFileRead(offset, bytes_to_read));
- tester.Run();
-}
-
-// Test complete read of a file in one operation.
-void TestCompleteReadFile(PP_FileSystemType system_type) {
- PP_FileInfo file_info = { 0 };
- InitFileInfo(system_type, &file_info);
-
- FileIOTester tester(file_info);
- tester.AddSequenceElement(new OpenFileForTest);
- tester.AddSequenceElement(new TestFileRead(0, // start at beginning
- strlen(kTestData)));
- tester.Run();
-}
-
-void TestParallelReadFile(PP_FileSystemType system_type) {
- PP_FileInfo file_info = { 0 };
- InitFileInfo(system_type, &file_info);
-
- const int64_t offset = strlen(kTestData) / 2;
- const int32_t bytes_to_read = strlen(kTestData) / 3;
-
- FileIOTester tester(file_info);
- tester.AddSequenceElement(new OpenFileForTest);
- tester.AddSequenceElement(new TestParallelRead(offset, bytes_to_read));
- tester.Run();
-}
-
-} // namespace
-
-void TestPartialFileReadLocalTemporary() {
- TestPartialFileRead(PP_FILESYSTEMTYPE_LOCALTEMPORARY);
- TEST_PASSED;
-}
-
-void TestCompleteReadLocalTemporary() {
- TestCompleteReadFile(PP_FILESYSTEMTYPE_LOCALTEMPORARY);
- TEST_PASSED;
-}
-
-// Test multiple reads of a file using multiple callbacks and different offsets.
-void TestParallelReadLocalTemporary() {
- TestParallelReadFile(PP_FILESYSTEMTYPE_LOCALTEMPORARY);
- TEST_PASSED;
-}
diff --git a/ppapi/native_client/tests/ppapi_browser/ppb_file_io/test_sequence_element.cc b/ppapi/native_client/tests/ppapi_browser/ppb_file_io/test_sequence_element.cc
deleted file mode 100644
index a325b9e..0000000
--- a/ppapi/native_client/tests/ppapi_browser/ppb_file_io/test_sequence_element.cc
+++ /dev/null
@@ -1,104 +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 "ppapi/native_client/tests/ppapi_browser/ppb_file_io/test_sequence_element.h"
-
-#include "native_client/src/include/nacl_scoped_ptr.h"
-#include "ppapi/c/ppb_core.h"
-#include "ppapi/native_client/tests/ppapi_test_lib/get_browser_interface.h"
-
-namespace common {
-
-TestSequenceElement::~TestSequenceElement() {}
-
-// TestSequenceElementForwardingCallback is the completion callback which
-// connects one test sequence element to another.
-void TestSequenceElement::TestSequenceElementForwardingCallback(
- void* data,
- int32_t result) {
- TestCallbackData* callback_data = reinterpret_cast<TestCallbackData*>(data);
- // If result is greater than 0, it is a result of a read/write. In that case
- // we ignore the result since it represents the number of bytes read/written,
- // which is not guaranteed to be a specific size.
- if (result <= 0)
- EXPECT(result == callback_data->expected_result);
- nacl::scoped_ptr<TestSequenceElement> sequence_element(
- callback_data->test_sequence.front());
- sequence_element->Run(callback_data, result);
-}
-
-// TODO(sanga): Move this to file_io_tester.h
-void TestSequenceElement::CleanupResources(
- TestCallbackData* callback_data) { // sink
- PPBCore()->ReleaseResource(callback_data->existing_file_io);
- PPBCore()->ReleaseResource(callback_data->existing_file_ref);
- PPBCore()->ReleaseResource(callback_data->non_existing_file_io);
- PPBCore()->ReleaseResource(callback_data->non_existing_file_ref);
- PPBCore()->ReleaseResource(callback_data->file_system);
- delete callback_data;
-}
-
-void TestSequenceElement::Run(TestCallbackData* callback_data, int32_t result) {
- callback_data->expected_return_value = expected_return_value_;
- callback_data->expected_result = expected_result_;
- Setup(callback_data);
- Execute(callback_data);
- // Invoke a ppapi function that kicks off another callback.
- callback_data->test_sequence.pop_front(); // pop self off the dequeue
- Next(callback_data);
-}
-
-void TestSequenceElement::TestSequenceTerminatingCallback(void* data,
- int32_t result) {
- TestCallbackData* callback_data = reinterpret_cast<TestCallbackData*>(data);
- // If result is greater than 0, it is a result of a read/write. In that case
- // we ignore the result since it represents the number of bytes read/written,
- // which is not guaranteed to be a specific size.
- if (result <= 0)
- EXPECT(result == callback_data->expected_result);
- CleanupResources(callback_data);
-}
-
-namespace {
-
-int32_t CallbackInvokingNoOpFunction(int32_t delay_in_milliseconds,
- PP_CompletionCallback callback) {
- PPBCore()->CallOnMainThread(delay_in_milliseconds, callback, PP_OK);
- return PP_OK_COMPLETIONPENDING;
-}
-
-} // namespace
-
-BoundPPAPIFunc
-TestSequenceElement::GetCompletionCallbackInitiatingPPAPIFunction(
- TestCallbackData* /*callback_data*/) {
- return std::tr1::bind(CallbackInvokingNoOpFunction, 0,
- std::tr1::placeholders::_1);
-}
-
-void TestSequenceElement::Next(TestCallbackData* callback_data) {
- PP_CompletionCallback_Func callback_func = NULL;
- std::string callback_name = "END";
- if (!callback_data->test_sequence.empty()) {
- callback_func = TestSequenceElementForwardingCallback;
- TestSequenceElement* next_element = callback_data->test_sequence.front();
- callback_name = next_element->name();
- } else {
- callback_func = TestSequenceTerminatingCallback;
- }
- PP_CompletionCallback completion_callback = MakeTestableCompletionCallback(
- callback_name.c_str(), callback_func, callback_data);
- BoundPPAPIFunc ppapi_func =
- GetCompletionCallbackInitiatingPPAPIFunction(callback_data);
- int32_t pp_error = ppapi_func(completion_callback);
- EXPECT(pp_error == callback_data->expected_return_value);
- if (pp_error != PP_OK_COMPLETIONPENDING) {
- // We need to invoke to the next callback.
- PPBCore()->CallOnMainThread(0, // no delay
- completion_callback,
- callback_data->expected_result);
- }
-}
-
-} // namespace common
diff --git a/ppapi/native_client/tests/ppapi_browser/ppb_file_io/test_sequence_element.h b/ppapi/native_client/tests/ppapi_browser/ppb_file_io/test_sequence_element.h
deleted file mode 100644
index 04d9e74..0000000
--- a/ppapi/native_client/tests/ppapi_browser/ppb_file_io/test_sequence_element.h
+++ /dev/null
@@ -1,131 +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.
-#ifndef NATIVE_CLIENT_TESTS_PPAPI_BROWSER_PPB_FILE_IO_TEST_SEQUENCE_ELEMENT_H_
-#define NATIVE_CLIENT_TESTS_PPAPI_BROWSER_PPB_FILE_IO_TEST_SEQUENCE_ELEMENT_H_
-
-#include <deque>
-#include <string>
-#include <tr1/functional>
-
-#include "native_client/src/include/nacl_base.h"
-#include "ppapi/c/pp_errors.h"
-#include "ppapi/c/pp_file_info.h"
-#include "ppapi/native_client/tests/ppapi_test_lib/test_interface.h"
-
-namespace common {
-
-class TestSequenceElement;
-
-// TestCallbackData is used to pass data from on test sequence element to
-// another, e.g. file io, file ref, etc.
-struct TestCallbackData {
- TestCallbackData(PP_Resource system,
- PP_FileInfo info,
- std::deque<TestSequenceElement*> sequence)
- : file_system(system), file_info(info),
- existing_file_io(kInvalidResource), existing_file_ref(kInvalidResource),
- non_existing_file_io(kInvalidResource),
- non_existing_file_ref(kInvalidResource), expected_result(PP_OK),
- expected_return_value(PP_OK_COMPLETIONPENDING), data(NULL),
- test_sequence(sequence) {}
-
- const PP_Resource file_system;
- const PP_FileInfo file_info;
- PP_Resource existing_file_io;
- PP_Resource existing_file_ref;
- PP_Resource non_existing_file_io;
- PP_Resource non_existing_file_ref;
- // The following known properties of the file assigned to the file before
- // testing.
- int32_t expected_result; // The expected result of a callback operation.
- int32_t expected_return_value;
- void* data; // Used to attach contextual data
- // Array of test functions that themselve can invoke functions which trigger a
- // callback.
- std::deque<TestSequenceElement*> test_sequence;
-};
-
-// OpenFileForTest is an element in a test sequence used to open the existing
-typedef std::tr1::function<int32_t (PP_CompletionCallback)> BoundPPAPIFunc;
-
-// TestSequenceElement is a specific section of a sequence of tests.
-// Each element may or may not have side effects that effect the subsequent test
-// sequence elements (e.g. opening or closing a file).
-// Example:
-// class ConcreteTestElement : public TestSequenceElement {
-// private:
-// virtual BoundPPAPIFunc
-// GetCompletionCallbackInitiatingPPAPIFunction(
-// TestCallbackData* callback_data) {
-// return std::tr1::bind(PPBFileRef()->Delete,
-// callback_data->existing_file_ref,
-// std::tr1::placeholder::_1);
-// }
-//
-// void TestFoo() {
-// PP_FileInfo file_info;
-// InitFileInfo(PP_FILESYSTEMTYPE_LOCALTEMPORARY, &file_info);
-// FileIOTester tester(file_info);
-// tester.AddSequenceElement(new ConcreteTestElement);
-// tester.Run();
-// }
-class TestSequenceElement {
- public:
- explicit TestSequenceElement(const std::string& name)
- : name_(name), expected_return_value_(PP_OK_COMPLETIONPENDING),
- expected_result_(PP_OK) {}
- TestSequenceElement(const std::string& name, int32_t expected_return_value,
- int32_t expected_result)
- : name_(name), expected_return_value_(expected_return_value),
- expected_result_(expected_result) {}
- virtual ~TestSequenceElement();
-
- // TestSequenceElementForwardingCallback is the callback that is called from
- // the previous sequence element's invocation of a ppapi function which calls
- // a completion callback.
- static void TestSequenceElementForwardingCallback(void* data, int32_t result);
- static void CleanupResources(TestCallbackData* callback_data);
-
- // Run executes the element's section of the test sequence.
- // |callback_data| is a pointer to data being passed through each element.
- // |result| is the result of the ppapi operation invoked by previous element
- // in the test sequence.
- void Run(TestCallbackData* callback_data,
- int32_t result);
- const char* name() { return name_.c_str(); }
-
- private:
- TestSequenceElement(); // Disable default ctor
-
- static void TestSequenceTerminatingCallback(void* data, int32_t result);
-
- // Returns a PPAPI function that initiates a completion callback. This is
- // produced by taking a PPAPI function that takes a completion callback as the
- // last argument and possibly binding every other parameter with values from
- // the given test data (e.g.):
- // return std::tr1::bind(PPB_FileRef()->Delete,
- // callback_data->existing_file_ref,
- // std::tr1::_1)
- // Subclasses define this function to chain the test sequence element with
- // ppapi functions.
- virtual BoundPPAPIFunc GetCompletionCallbackInitiatingPPAPIFunction(
- TestCallbackData* callback_data);
- // Set up. Can be a no-op if not defined by subcass.
- virtual void Setup(TestCallbackData* callback_data) {}
- // Implemented by subclasses to verify results of previously test sequence
- // elements or modify known states for subsequent test elements.
- virtual void Execute(TestCallbackData* callback_data) {}
-
- void Next(TestCallbackData* callback_data);
-
- const std::string name_;
- const int32_t expected_return_value_;
- const int32_t expected_result_;
-
- DISALLOW_COPY_AND_ASSIGN(TestSequenceElement);
-};
-
-} // namespace common
-
-#endif // NATIVE_CLIENT_TESTS_PPAPI_BROWSER_PPB_FILE_IO_TEST_SEQUENCE_ELEMENT_H_
diff --git a/ppapi/native_client/tests/ppapi_browser/ppb_graphics2d/nacl.scons b/ppapi/native_client/tests/ppapi_browser/ppb_graphics2d/nacl.scons
deleted file mode 100644
index 6a1f9d9..0000000
--- a/ppapi/native_client/tests/ppapi_browser/ppb_graphics2d/nacl.scons
+++ /dev/null
@@ -1,44 +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_graphics2d')
-
-nexe = env.ProgramNameForNmf('ppapi_ppb_graphics2d')
-env.Alias('ppapi_ppb_graphics2d${PROGSUFFIX}',
- ['$STAGING_DIR/%s${PROGSUFFIX}' % nexe])
-
-ppapi_ppb_graphics2d_nexe = env.ComponentProgram(
- nexe,
- [ 'ppapi_ppb_graphics2d.cc' ],
- EXTRA_LIBS=['ppapi',
- 'ppapi_test_lib',
- 'platform', # for CHECK
- 'pthread',
- 'gio',
- ])
-
-dest_copy = env.Publish(nexe, 'run',
- [ 'ppapi_ppb_graphics2d.html',
- env.File('${SCONSTRUCT_DIR}/tools/browser_tester/'
- 'browserdata/nacltest.js') ]
- )
-
-node = env.PPAPIBrowserTester('ppapi_ppb_graphics2d_browser_test.out',
- url='ppapi_ppb_graphics2d.html',
- nmf_names=['ppapi_ppb_graphics2d'],
- files=[ ppapi_ppb_graphics2d_nexe,
- env.File('ppapi_ppb_graphics2d.html')],
- browser_flags=['--enable-pepper-testing'])
-
-env.AddNodeToTestSuite(node,
- ['chrome_browser_tests'],
- 'run_ppapi_ppb_graphics2d_browser_test',
- is_broken=env.PPAPIBrowserTesterIsBroken())
diff --git a/ppapi/native_client/tests/ppapi_browser/ppb_graphics2d/ppapi_ppb_graphics2d.cc b/ppapi/native_client/tests/ppapi_browser/ppb_graphics2d/ppapi_ppb_graphics2d.cc
deleted file mode 100644
index eed0bdd..0000000
--- a/ppapi/native_client/tests/ppapi_browser/ppb_graphics2d/ppapi_ppb_graphics2d.cc
+++ /dev/null
@@ -1,476 +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.
-//
-// Test cases for PPB_Graphics2D functions.
-// As most of them return void, the test automatically confirms that
-// there is no crash while requiring a visual inspection of the painted output.
-
-#include <string.h>
-
-#include "native_client/src/include/nacl_macros.h"
-#include "native_client/src/shared/platform/nacl_check.h"
-#include "native_client/tests/ppapi_test_lib/get_browser_interface.h"
-#include "native_client/tests/ppapi_test_lib/test_interface.h"
-#include "ppapi/c/dev/ppb_testing_dev.h"
-#include "ppapi/c/pp_bool.h"
-#include "ppapi/c/pp_errors.h"
-#include "ppapi/c/pp_point.h"
-#include "ppapi/c/pp_rect.h"
-#include "ppapi/c/pp_size.h"
-#include "ppapi/c/ppb_core.h"
-#include "ppapi/c/ppb_graphics_2d.h"
-#include "ppapi/c/ppb_image_data.h"
-#include "ppapi/c/ppb_instance.h"
-#include "ppapi/c/ppb_url_loader.h"
-
-namespace {
-
-const PP_Bool kAlwaysOpaque = PP_TRUE;
-const PP_Bool kNotAlwaysOpaque = PP_FALSE;
-const PP_Size kNegativeWidth = PP_MakeSize(-1, 1);
-const PP_Size kNegativeHeight = PP_MakeSize(1, -1);
-const PP_Size kZeroPixels = PP_MakeSize(0, 0);
-const PP_Size kOnePixel = PP_MakeSize(1, 1);
-const PP_Size k90x90 = PP_MakeSize(90, 90);
-const PP_Size k60x60 = PP_MakeSize(60, 60);
-const PP_Size k30x30 = PP_MakeSize(30, 30);
-const PP_Size k2500x2500 = PP_MakeSize(2500, 2500);
-const PP_Size k100000x100000 = PP_MakeSize(100000, 100000);
-const PP_Rect kBadRect = { PP_MakePoint(-1, -1), PP_MakeSize(-1, -1) };
-const PP_Rect* kEntireImage = NULL;
-const PP_Bool kInitToZero = PP_TRUE;
-
-
-// Make graphics2d contexts for each test the same size, so we can layer
-// the images without invalidating the previous ones.
-PP_Resource CreateGraphics2D_90x90() {
- PP_Resource graphics2d = PPBGraphics2D()->Create(
- pp_instance(), &k90x90, kNotAlwaysOpaque);
- CHECK(graphics2d != kInvalidResource);
- PPBInstance()->BindGraphics(pp_instance(), graphics2d);
- return graphics2d;
-}
-
-PP_Resource CreateImageData(PP_Size size, ColorPremul pixel_color) {
- void* bitmap = NULL;
- return CreateImageData(size, pixel_color, &bitmap);
-}
-
-struct FlushData {
- FlushData(PP_Resource g, PP_Resource i) : graphics2d(g), image_data(i) {}
- PP_Resource graphics2d;
- PP_Resource image_data;
-};
-
-void FlushCallback(void* user_data, int32_t result);
-int g_expected_flush_calls = 0;
-PP_CompletionCallback MakeTestableFlushCallback(const char* name,
- PP_Resource graphics2d,
- PP_Resource image_data,
- int num_calls) {
- g_expected_flush_calls = num_calls;
- void* user_data = new FlushData(graphics2d, image_data);
- return MakeTestableCompletionCallback(name, FlushCallback, user_data);
-}
-
-void FlushCallback(void* user_data, int32_t result) {
- --g_expected_flush_calls;
- CHECK(g_expected_flush_calls >= 0);
- CHECK(user_data != NULL);
- CHECK(result == PP_OK);
-
- FlushData* data = static_cast<FlushData*>(user_data);
- PP_Resource graphics2d = data->graphics2d;
- PP_Resource image_data = data->image_data;
- if (g_expected_flush_calls == 0) {
- PPBCore()->ReleaseResource(graphics2d);
- PPBCore()->ReleaseResource(image_data);
- delete data;
- } else {
- PPBGraphics2D()->PaintImageData(graphics2d, image_data, &kOrigin, NULL);
- PP_CompletionCallback cc = MakeTestableFlushCallback(
- "FlushAnimationCallback",
- graphics2d, image_data, g_expected_flush_calls);
- CHECK(PP_OK_COMPLETIONPENDING == PPBGraphics2D()->Flush(graphics2d, cc));
- }
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// Test Cases
-////////////////////////////////////////////////////////////////////////////////
-
-// Tests PPB_Graphics2D::Create().
-void TestCreate() {
- PP_Resource graphics2d = kInvalidResource;
- const PPB_Graphics2D* ppb = PPBGraphics2D();
-
- // Invalid instance and size -> invalid resource.
- graphics2d = ppb->Create(kInvalidInstance, &k30x30, kAlwaysOpaque);
- EXPECT(graphics2d == kInvalidResource);
- graphics2d = ppb->Create(kInvalidInstance, &k30x30, kNotAlwaysOpaque);
- EXPECT(graphics2d == kInvalidResource);
- graphics2d = ppb->Create(kNotAnInstance, &k30x30, kAlwaysOpaque);
- EXPECT(graphics2d == kInvalidResource);
- graphics2d = ppb->Create(kNotAnInstance, &k30x30, kNotAlwaysOpaque);
- EXPECT(graphics2d == kInvalidResource);
- graphics2d = ppb->Create(pp_instance(), &k100000x100000, kAlwaysOpaque);
- EXPECT(graphics2d == kInvalidResource);
- graphics2d = ppb->Create(pp_instance(), &k100000x100000, kNotAlwaysOpaque);
- EXPECT(graphics2d == kInvalidResource);
- graphics2d = ppb->Create(pp_instance(), &kZeroPixels, kAlwaysOpaque);
- EXPECT(graphics2d == kInvalidResource);
- graphics2d = ppb->Create(pp_instance(), &kZeroPixels, kNotAlwaysOpaque);
- EXPECT(graphics2d == kInvalidResource);
- graphics2d = ppb->Create(pp_instance(), &kNegativeWidth, kAlwaysOpaque);
- EXPECT(graphics2d == kInvalidResource);
- graphics2d = ppb->Create(pp_instance(), &kNegativeHeight, kNotAlwaysOpaque);
- EXPECT(graphics2d == kInvalidResource);
- // NULL size -> Internal error in rpc method.
- graphics2d = ppb->Create(pp_instance(), NULL, kAlwaysOpaque);
- EXPECT(graphics2d == kInvalidResource);
- graphics2d = ppb->Create(pp_instance(), NULL, kNotAlwaysOpaque);
- EXPECT(graphics2d == kInvalidResource);
-
- // Valid instance and size -> valid resource.
- graphics2d = ppb->Create(pp_instance(), &kOnePixel, kAlwaysOpaque);
- EXPECT(graphics2d != kInvalidResource);
- PPBCore()->ReleaseResource(graphics2d);
- graphics2d = ppb->Create(pp_instance(), &kOnePixel, kNotAlwaysOpaque);
- EXPECT(graphics2d != kInvalidResource);
- PPBCore()->ReleaseResource(graphics2d);
- graphics2d = ppb->Create(pp_instance(), &k30x30, kAlwaysOpaque);
- EXPECT(graphics2d != kInvalidResource);
- PPBCore()->ReleaseResource(graphics2d);
- graphics2d = ppb->Create(pp_instance(), &k30x30, kNotAlwaysOpaque);
- EXPECT(graphics2d != kInvalidResource);
- PPBCore()->ReleaseResource(graphics2d);
- graphics2d = ppb->Create(pp_instance(), &k2500x2500, kAlwaysOpaque);
- EXPECT(graphics2d != kInvalidResource);
- PPBCore()->ReleaseResource(graphics2d);
- graphics2d = ppb->Create(pp_instance(), &k2500x2500, kNotAlwaysOpaque);
- EXPECT(graphics2d != kInvalidResource);
- PPBCore()->ReleaseResource(graphics2d);
-
- TEST_PASSED;
-}
-
-// Tests PPB_Graphics2D::IsGraphics2D().
-void TestIsGraphics2D() {
- // Invalid / non-existent / non-Graphics2D resource -> false.
- EXPECT(PP_FALSE == PPBGraphics2D()->IsGraphics2D(kInvalidResource));
- EXPECT(PP_FALSE == PPBGraphics2D()->IsGraphics2D(kNotAResource));
- PP_Resource url_loader = PPBURLLoader()->Create(pp_instance());
- CHECK(url_loader != kInvalidResource);
- EXPECT(PP_FALSE == PPBGraphics2D()->IsGraphics2D(url_loader));
- PPBCore()->ReleaseResource(url_loader);
-
- // Current Graphics2D resource -> true.
- PP_Resource graphics2d = PPBGraphics2D()->Create(
- pp_instance(), &k30x30, kAlwaysOpaque);
- EXPECT(PP_TRUE == PPBGraphics2D()->IsGraphics2D(graphics2d));
-
- // Released Graphis2D resource -> false.
- PPBCore()->ReleaseResource(graphics2d);
- EXPECT(PP_FALSE == PPBGraphics2D()->IsGraphics2D(graphics2d));
-
- TEST_PASSED;
-}
-
-// Tests PPB_Graphics2D::Describe().
-void TestDescribe() {
- PP_Resource graphics2d = kInvalidResource;
- const PPB_Graphics2D* ppb = PPBGraphics2D();
- struct PP_Size size = k90x90;
- PP_Bool is_always_opaque = PP_TRUE;
-
- // Valid resource -> output = configuration, true.
- graphics2d = ppb->Create(pp_instance(), &k30x30, kNotAlwaysOpaque);
- EXPECT(PP_TRUE == ppb->Describe(graphics2d, &size, &is_always_opaque));
- EXPECT(is_always_opaque == PP_FALSE && IsSizeEqual(size, k30x30));
- PPBCore()->ReleaseResource(graphics2d);
-
- graphics2d = ppb->Create(pp_instance(), &k30x30, kAlwaysOpaque);
- EXPECT(PP_TRUE == ppb->Describe(graphics2d, &size, &is_always_opaque));
- EXPECT(is_always_opaque == PP_TRUE && IsSizeEqual(size, k30x30));
- PPBCore()->ReleaseResource(graphics2d);
-
- // NULL outputs -> output = unchanged, false.
- EXPECT(PP_FALSE == ppb->Describe(graphics2d, NULL, &is_always_opaque));
- EXPECT(PP_FALSE == ppb->Describe(graphics2d, &size, NULL));
- EXPECT(is_always_opaque == PP_TRUE && IsSizeEqual(size, k30x30));
-
- // Invalid / non-existent resource -> output = 0, false.
- EXPECT(PP_FALSE == ppb->Describe(kInvalidResource, &size, &is_always_opaque));
- EXPECT(is_always_opaque == PP_FALSE && IsSizeEqual(size, kZeroPixels));
-
- is_always_opaque = PP_TRUE;
- size = k90x90;
- EXPECT(PP_FALSE == ppb->Describe(kNotAResource, &size, &is_always_opaque));
- EXPECT(is_always_opaque == PP_FALSE && IsSizeEqual(size, kZeroPixels));
-
- TEST_PASSED;
-}
-
-// Tests PPB_Graphics2D::PaintImageData() with specified image rect.
-// Draws a blue square in the top right corner.
-// Requires a visual inspection.
-void TestPaintImageData() {
- const PPB_Graphics2D* ppb = PPBGraphics2D();
- PP_Resource graphics2d = CreateGraphics2D_90x90();
- PP_Resource image_data = CreateImageData(k60x60, kSheerBlue);
- PP_Resource image_data_noop = CreateImageData(k60x60, kOpaqueBlack);
- PP_Rect src_rect = { PP_MakePoint(30, 30), k30x30 };
- PP_Point top_left = PP_MakePoint(30, -30); // target origin = (60, 0);
- PP_Point clip_up = PP_MakePoint(0, -31); // target origin = (30, -1)
- PP_Point clip_left = PP_MakePoint(-31, 0); // target origin = (-1, 30)
- PP_Point clip_right = PP_MakePoint(31, 0); // target origin = (61, 30)
- PP_Point clip_down = PP_MakePoint(0, 31); // target origin = (30, 61)
-
- // Valid args -> copies to backing store and paints to screen after Flush().
- ppb->PaintImageData(graphics2d, image_data, &top_left, &src_rect);
-
- // Invalid args -> no effect, no crash.
- ppb->PaintImageData(kInvalidResource, image_data_noop, &top_left, &src_rect);
- ppb->PaintImageData(kNotAResource, image_data_noop, &top_left, &src_rect);
- ppb->PaintImageData(graphics2d, kInvalidResource, &top_left, &src_rect);
- ppb->PaintImageData(graphics2d, kNotAResource, &top_left, &src_rect);
- ppb->PaintImageData(graphics2d, image_data_noop, &clip_up, &src_rect);
- ppb->PaintImageData(graphics2d, image_data_noop, &clip_left, &src_rect);
- ppb->PaintImageData(graphics2d, image_data_noop, &clip_right, &src_rect);
- ppb->PaintImageData(graphics2d, image_data_noop, &clip_down, &src_rect);
- ppb->PaintImageData(graphics2d, image_data_noop, &kOrigin, &kBadRect);
- // NULL top_left - > Internal error in rpc method.
- ppb->PaintImageData(graphics2d, image_data_noop, NULL, &src_rect);
- ppb->PaintImageData(kInvalidResource, kNotAResource, NULL, &src_rect);
-
- // Paints backing store image to screen only after Flush().
- PP_Point top_right = PP_MakePoint(60, 0);
- EXPECT(!IsImageRectOnScreen(graphics2d, top_right, k30x30, kSheerBlue));
- PP_CompletionCallback cc = MakeTestableFlushCallback(
- "PaintImageDataFlushCallback", graphics2d, image_data, 1);
- EXPECT(PP_OK_COMPLETIONPENDING == ppb->Flush(graphics2d, cc));
- EXPECT(IsImageRectOnScreen(graphics2d, top_right, k30x30, kSheerBlue));
-
- // This should have no effect on Flush().
- ppb->PaintImageData(graphics2d, image_data_noop, &top_left, &src_rect);
- PPBCore()->ReleaseResource(image_data_noop);
-
- TEST_PASSED;
-}
-
-// Tests PPB_Graphics2D::PaintImageData() with default rect for entire image.
-// Draws a yellow square in the bottom left corner.
-// Requires a visual inspection.
-void TestPaintImageDataEntire() {
- const PPB_Graphics2D* ppb = PPBGraphics2D();
- PP_Resource graphics2d = CreateGraphics2D_90x90();
- PP_Resource image_data = CreateImageData(k30x30, kOpaqueYellow);
- PP_Resource image_data_noop = CreateImageData(k30x30, kOpaqueBlack);
- PP_Point bottom_left = PP_MakePoint(0, 60);
- PP_Point clip_up = PP_MakePoint(0, -1);
- PP_Point clip_left = PP_MakePoint(-1, 0);
- PP_Point clip_right = PP_MakePoint(61, 0);
- PP_Point clip_down = PP_MakePoint(0, 61);
-
- // Valid args -> copies to backing store.
- ppb->PaintImageData(graphics2d, image_data, &bottom_left, kEntireImage);
-
- // Invalid args -> no effect, no crash.
- ppb->PaintImageData(
- kInvalidResource, image_data_noop, &bottom_left, kEntireImage);
- ppb->PaintImageData(
- kNotAResource, image_data_noop, &bottom_left, kEntireImage);
- ppb->PaintImageData(graphics2d, kInvalidResource, &bottom_left, kEntireImage);
- ppb->PaintImageData(graphics2d, kNotAResource, &bottom_left, kEntireImage);
- ppb->PaintImageData(graphics2d, image_data_noop, &clip_up, kEntireImage);
- ppb->PaintImageData(graphics2d, image_data_noop, &clip_left, kEntireImage);
- ppb->PaintImageData(graphics2d, image_data_noop, &clip_right, kEntireImage);
- ppb->PaintImageData(graphics2d, image_data_noop, &clip_down, kEntireImage);
- // NULL top_left - > Internal error in rpc method.
- ppb->PaintImageData(graphics2d, image_data_noop, NULL, kEntireImage);
- ppb->PaintImageData(kInvalidResource, kNotAResource, NULL, kEntireImage);
-
- // Paints backing store image to the screen only after Flush().
- EXPECT(!IsImageRectOnScreen(graphics2d, bottom_left, k30x30, kOpaqueYellow));
- PP_CompletionCallback cc = MakeTestableFlushCallback(
- "PaintImageDataEntireFlushCallback", graphics2d, image_data, 1);
- EXPECT(PP_OK_COMPLETIONPENDING == ppb->Flush(graphics2d, cc));
- EXPECT(IsImageRectOnScreen(graphics2d, bottom_left, k30x30, kOpaqueYellow));
-
- // This should have no effect on Flush().
- ppb->PaintImageData(graphics2d, image_data_noop, &bottom_left, kEntireImage);
- PPBCore()->ReleaseResource(image_data_noop);
-
- TEST_PASSED;
-}
-
-// Tests PPB_Graphics2D::Scroll() with specified image rect.
-// Draws a white square at the top left, then in the middle.
-// Requires a visual inspection.
-void TestScroll() {
- const PPB_Graphics2D* ppb = PPBGraphics2D();
- PP_Resource graphics2d = CreateGraphics2D_90x90();
- PP_Resource image_data = CreateImageData(k30x30, kOpaqueWhite);
- PP_Rect src_rect = { kOrigin, k30x30 };
- PP_Rect clip_rect = { kOrigin, k60x60 };
- PP_Point middle = PP_MakePoint(30, 30);
- ppb->PaintImageData(graphics2d, image_data, &kOrigin, &src_rect);
-
- // Valid args -> scrolls backing store and paints to screen after Flush().
- ppb->Scroll(graphics2d, &clip_rect, &middle);
-
- // Invalid args -> no effect, no crash.
- ppb->Scroll(kInvalidResource, &clip_rect, &middle);
- ppb->Scroll(kNotAResource, &clip_rect, &middle);
- ppb->Scroll(graphics2d, &clip_rect, NULL); // Internal error in rpc method.
-
- // Paints backing store image to the sreen only after Flush().
- EXPECT(!IsImageRectOnScreen(graphics2d, middle, k30x30, kOpaqueWhite));
- PP_CompletionCallback cc = MakeTestableFlushCallback(
- "ScrollFlushCallback", graphics2d, image_data, 1);
- EXPECT(PP_OK_COMPLETIONPENDING == ppb->Flush(graphics2d, cc));
- EXPECT(IsImageRectOnScreen(graphics2d, middle, k30x30, kOpaqueWhite));
-
- TEST_PASSED;
-}
-
-// Tests PPB_Graphics2D::Scroll() with default rect for entire image..
-// Draws a green square in the top left, then bottom right.
-// Requires a visual inspection.
-void TestScrollEntire() {
- const PPB_Graphics2D* ppb = PPBGraphics2D();
- PP_Resource graphics2d = CreateGraphics2D_90x90();
- PP_Resource image_data = CreateImageData(k30x30, kOpaqueGreen);
- PP_Point bottom_right = PP_MakePoint(60, 60);
- ppb->PaintImageData(graphics2d, image_data, &kOrigin, kEntireImage);
-
- // Valid args -> scrolls backing store and paints to screen after Flush().
- ppb->Scroll(graphics2d, kEntireImage, &bottom_right);
-
- // Invalid args -> no crash.
- ppb->Scroll(kInvalidResource, kEntireImage, &bottom_right);
- ppb->Scroll(kNotAResource, kEntireImage, &bottom_right);
- ppb->Scroll(graphics2d, kEntireImage, NULL); // Internal error in rpc method.
-
- // Paints backing store image to the screen only after Flush().
- EXPECT(!IsImageRectOnScreen(graphics2d, bottom_right, k30x30, kOpaqueGreen));
- ppb->Scroll(graphics2d, kEntireImage, &bottom_right);
- PP_CompletionCallback cc = MakeTestableFlushCallback(
- "ScrollEntireFlushCallback", graphics2d, image_data, 1);
- EXPECT(PP_OK_COMPLETIONPENDING == ppb->Flush(graphics2d, cc));
- EXPECT(IsImageRectOnScreen(graphics2d, bottom_right, k30x30, kOpaqueGreen));
-
- TEST_PASSED;
-}
-
-// Tests PPB_Graphics2D::ReplaceContents().
-// Colors the entire graphics area gray.
-// Requires a visual inspection.
-void TestReplaceContents() {
- PP_Resource graphics2d = CreateGraphics2D_90x90();
- PP_Resource image_data = CreateImageData(k90x90, kSheerGray);
- PP_Resource image_data_noop = CreateImageData(k90x90, kOpaqueBlack);
- PP_Resource image_data_size_mismatch = CreateImageData(k30x30, kOpaqueBlack);
-
- // Valid args -> replaces backing store.
- PPBGraphics2D()->ReplaceContents(graphics2d, image_data);
-
- // Invalid args -> no effect, no crash.
- PPBGraphics2D()->ReplaceContents(kInvalidResource, image_data_noop);
- PPBGraphics2D()->ReplaceContents(kNotAResource, image_data_noop);
- PPBGraphics2D()->ReplaceContents(graphics2d, kInvalidResource);
- PPBGraphics2D()->ReplaceContents(graphics2d, kNotAResource);
- PPBGraphics2D()->ReplaceContents(kInvalidResource, kNotAResource);
- PPBGraphics2D()->ReplaceContents(graphics2d, image_data_size_mismatch);
-
- // Paints backing store image to the screen only after Flush().
- EXPECT(!IsImageRectOnScreen(graphics2d, kOrigin, k90x90, kSheerGray));
- PP_CompletionCallback cc = MakeTestableFlushCallback(
- "ReplaceContentsFlushCallback", graphics2d, image_data, 1);
- EXPECT(PP_OK_COMPLETIONPENDING == PPBGraphics2D()->Flush(graphics2d, cc));
- EXPECT(IsImageRectOnScreen(graphics2d, kOrigin, k90x90, kSheerGray));
-
- // This should have no effect on Flush().
- PPBGraphics2D()->ReplaceContents(graphics2d, image_data_noop);
- PPBCore()->ReleaseResource(image_data_noop);
- PPBCore()->ReleaseResource(image_data_size_mismatch);
-
- TEST_PASSED;
-}
-
-// Tests PPB_Graphics2D::Flush().
-void TestFlush() {
- PP_Resource graphics2d = PPBGraphics2D()->Create(
- pp_instance(), &k90x90, kAlwaysOpaque);
- PP_CompletionCallback cc = MakeTestableFlushCallback(
- "FlushCallback", graphics2d, kInvalidResource, 1);
-
- // Invalid args -> PP_ERROR_BAD..., no callback.
- EXPECT(PP_ERROR_BADRESOURCE == PPBGraphics2D()->Flush(kInvalidResource, cc));
- EXPECT(PP_ERROR_BADRESOURCE == PPBGraphics2D()->Flush(kNotAResource, cc));
- EXPECT(PP_ERROR_BLOCKS_MAIN_THREAD ==
- PPBGraphics2D()->Flush(graphics2d, PP_BlockUntilComplete()));
-
- // Valid args -> PP_OK_COMPLETIONPENDING, expect callback.
- EXPECT(PP_OK_COMPLETIONPENDING == PPBGraphics2D()->Flush(graphics2d, cc));
-
- // Duplicate call -> PP_ERROR_INPROGRESS, no callback.
- EXPECT(PP_ERROR_INPROGRESS == PPBGraphics2D()->Flush(graphics2d, cc));
-
- TEST_PASSED;
-}
-
-// Tests continious Paint/Flush chaining.
-void TestFlushAnimation() {
- PP_Resource graphics2d = CreateGraphics2D_90x90();
- PP_Resource image_data = CreateImageData(k30x30, kSheerRed);
-
- PPBGraphics2D()->PaintImageData(graphics2d, image_data, &kOrigin, NULL);
- PP_CompletionCallback cc = MakeTestableFlushCallback(
- "FlushAnimationCallback", graphics2d, image_data, 10);
- EXPECT(PP_OK_COMPLETIONPENDING == PPBGraphics2D()->Flush(graphics2d, cc));
-
- TEST_PASSED;
-}
-
-// Stress testing of a large number of resources.
-void TestStress() {
- // TODO(nfullagar): Increase the number of resources once the cause of the
- // stress test flake is fixed.
- const int kManyResources = 100;
- PP_Resource graphics2d[kManyResources];
- const PPB_Graphics2D* ppb = PPBGraphics2D();
-
- for (int i = 0; i < kManyResources; i++) {
- graphics2d[i] = ppb->Create(pp_instance(), &k30x30, kAlwaysOpaque);
- EXPECT(graphics2d[i] != kInvalidResource);
- EXPECT(PP_TRUE == ppb->IsGraphics2D(graphics2d[i]));
- }
- for (int i = 0; i < kManyResources; i++) {
- PPBCore()->ReleaseResource(graphics2d[i]);
- EXPECT(PP_FALSE == PPBGraphics2D()->IsGraphics2D(graphics2d[i]));
- }
-
- TEST_PASSED;
-}
-
-} // namespace
-
-void SetupTests() {
- RegisterTest("TestCreate", TestCreate);
- RegisterTest("TestIsGraphics2D", TestIsGraphics2D);
- RegisterTest("TestDescribe", TestDescribe);
- RegisterTest("TestPaintImageData", TestPaintImageData);
- RegisterTest("TestPaintImageDataEntire", TestPaintImageDataEntire);
- RegisterTest("TestScroll", TestScroll);
- RegisterTest("TestScrollEntire", TestScrollEntire);
- RegisterTest("TestReplaceContents", TestReplaceContents);
- RegisterTest("TestFlush", TestFlush);
- RegisterTest("TestFlushAnimation", TestFlushAnimation);
- RegisterTest("TestStress", TestStress);
-}
-
-void SetupPluginInterfaces() {
- // none
-}
diff --git a/ppapi/native_client/tests/ppapi_browser/ppb_graphics2d/ppapi_ppb_graphics2d.html b/ppapi/native_client/tests/ppapi_browser/ppb_graphics2d/ppapi_ppb_graphics2d.html
deleted file mode 100644
index 59b7d6d0..0000000
--- a/ppapi/native_client/tests/ppapi_browser/ppb_graphics2d/ppapi_ppb_graphics2d.html
+++ /dev/null
@@ -1,122 +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="application/x-javascript">
-//<![CDATA[
-function setupTests(tester, plugin) {
- function testAndAssertStatus(test, name, status) {
- var messageListener = test.wrap(function(message) {
- plugin.removeEventListener('message', messageListener, false);
- test.assertEqual(message.data, name + ':' + status);
- test.pass();
- });
- plugin.addEventListener('message', messageListener, false);
- plugin.postMessage(name);
- }
-
- function testAndAssertStatusAndCallbacks(test, name, status, callback, calls) {
- gotCalls = 0;
- var callbackListener = test.wrap(function(message) {
- plugin.removeEventListener('message', callbackListener, false);
- test.assertEqual(message.data, callback);
- if (++gotCalls < calls)
- plugin.addEventListener('message', callbackListener, false);
- else
- test.pass();
- });
- var messageListener = test.wrap(function(message) {
- plugin.removeEventListener('message', messageListener, false);
- test.assertEqual(message.data, name + ':' + status);
- plugin.addEventListener('message', callbackListener, false);
- });
- plugin.addEventListener('message', messageListener, false);
- plugin.postMessage(name);
- }
- tester.addAsyncTest('PPB_Graphics2D::Create', function(test) {
- testAndAssertStatus(test, 'TestCreate', 'PASSED');
- });
- tester.addAsyncTest('PPB_Graphics2D::IsGraphics2D', function(test) {
- testAndAssertStatus(test, 'TestIsGraphics2D', 'PASSED');
- });
- tester.addAsyncTest('PPB_Graphics2D::Describe', function(test) {
- testAndAssertStatus(test, 'TestDescribe', 'PASSED');
- });
- // This must be called first because it sets the entire graphics area to gray.
- tester.addAsyncTest('PPB_Graphics2D::ReplaceContents', function(test) {
- testAndAssertStatusAndCallbacks(test, 'TestReplaceContents', 'PASSED',
- 'ReplaceContentsFlushCallback', 1);
- });
- // Adds a blue square at the top right.
- tester.addAsyncTest('PPB_Graphics2D::PaintImageData', function(test) {
- testAndAssertStatusAndCallbacks(test, 'TestPaintImageData', 'PASSED',
- 'PaintImageDataFlushCallback', 1);
- });
- // Adds a yellow square at the bottom left.
- tester.addAsyncTest('PPB_Graphics2D::PaintImageDataEntire', function(test) {
- testAndAssertStatusAndCallbacks(test, 'TestPaintImageDataEntire', 'PASSED',
- 'PaintImageDataEntireFlushCallback', 1);
- });
- // Adds a white square at the top left and then the middle.
- tester.addAsyncTest('PPB_Graphics2D::Scroll', function(test) {
- testAndAssertStatusAndCallbacks(test, 'TestScroll', 'PASSED',
- 'ScrollFlushCallback', 1);
- });
- // Adds a green square at the top left (over white) and then the bottom right.
- tester.addAsyncTest('PPB_Graphics2D::ScrollEntire', function(test) {
- testAndAssertStatusAndCallbacks(test, 'TestScrollEntire', 'PASSED',
- 'ScrollEntireFlushCallback', 1);
- });
- // Does not alter the image.
- tester.addAsyncTest('PPB_Graphics2D::Flush', function(test) {
- testAndAssertStatusAndCallbacks(test, 'TestFlush', 'PASSED',
- 'FlushCallback', 1);
- });
- // Adds a red square at the top left (over green) 10 times.
- tester.addAsyncTest('PPB_Graphics2D::FlushAnimation', function(test) {
- testAndAssertStatusAndCallbacks(test, 'TestFlushAnimation', 'PASSED',
- 'FlushAnimationCallback', 10);
- });
- tester.addAsyncTest('PPB_Graphics2D::Stress', function(test) {
- testAndAssertStatus(test, 'TestStress', 'PASSED');
- });
-}
- //]]>
- </script>
- <title>PPAPI PPB_Graphics2D Test</title>
- </head>
- <body>
- <h1>PPAPI PPB_Graphics2D Test</h1>
- NOTE: requires --enable-pepper-testing
- <br><br>
- <table>
- <tr><td width="120"> Expected Image <td width="120">Actual Image
- <tr>
- <td>
- <table width="90" height="90" bgcolor="#DDDDDD" cellspacing="0">
- <tr><td bgcolor="#FF7777"><td><td bgcolor="#7777FF">
- <tr><td><td bgcolor="#FFFFFF"><td>
- <tr><td bgcolor="#FFFF00"><td><td bgcolor="#00FF00">
- </table>
- <td>
- <embed type="application/x-nacl" id="test_nexe"
- name="nacl_module"
- src="ppapi_ppb_graphics2d.nmf"
- style="background-color:#FFFFFF"
- width="90" height="90" />
- <table>
- <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/ppb_memory/nacl.scons b/ppapi/native_client/tests/ppapi_browser/ppb_memory/nacl.scons
deleted file mode 100644
index 4ac9ab6..0000000
--- a/ppapi/native_client/tests/ppapi_browser/ppb_memory/nacl.scons
+++ /dev/null
@@ -1,39 +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 tests PPB_Memory_Dev.
-
-Import('env')
-
-env.Prepend(CPPDEFINES=['XP_UNIX'])
-env.Replace(TEST_DIR='${SOURCE_ROOT}/ppapi/native_client/tests/ppapi_browser/' +
- 'ppb_memory')
-
-nexe = env.ProgramNameForNmf('ppapi_ppb_memory')
-env.Alias('ppapi_ppb_memory${PROGSUFFIX}',
- ['$STAGING_DIR/%s${PROGSUFFIX}' % nexe])
-
-ppapi_ppb_memory_nexe = env.ComponentProgram(
- nexe,
- ['ppapi_ppb_memory.cc'],
- EXTRA_LIBS=['ppapi',
- 'ppapi_test_lib',
- 'platform', # for CHECK
- 'pthread',
- 'gio',
- ])
-
-env.Publish(nexe, 'run',
- ['ppapi_ppb_memory.html'])
-
-node = env.PPAPIBrowserTester('ppapi_ppb_memory_browser_test.out',
- url='ppapi_ppb_memory.html',
- nmf_names=['ppapi_ppb_memory'],
- files=env.ExtractPublishedFiles(nexe))
-
-env.AddNodeToTestSuite(node,
- ['chrome_browser_tests'],
- 'run_ppapi_ppb_memory_browser_test',
- is_broken=env.PPAPIBrowserTesterIsBroken())
diff --git a/ppapi/native_client/tests/ppapi_browser/ppb_memory/ppapi_ppb_memory.cc b/ppapi/native_client/tests/ppapi_browser/ppb_memory/ppapi_ppb_memory.cc
deleted file mode 100644
index 6f55afd..0000000
--- a/ppapi/native_client/tests/ppapi_browser/ppb_memory/ppapi_ppb_memory.cc
+++ /dev/null
@@ -1,38 +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 "native_client/src/include/nacl_macros.h"
-#include "native_client/src/shared/platform/nacl_check.h"
-#include "native_client/tests/ppapi_test_lib/get_browser_interface.h"
-#include "native_client/tests/ppapi_test_lib/test_interface.h"
-
-#include "ppapi/c/pp_bool.h"
-#include "ppapi/c/pp_errors.h"
-#include "ppapi/c/dev/ppb_memory_dev.h"
-
-namespace {
-
-// Tests PPB_Memory_Dev::MemAlloc() and PPB_Core::MemFree().
-void TestMemAllocAndMemFree() {
- void* mem = NULL;
- mem = PPBMemoryDev()->MemAlloc(100); // No signficance to using 100
- EXPECT(mem != NULL);
- memset(mem, '-', 5);
- EXPECT(memcmp(mem, "-----", 5) == 0);
- PPBMemoryDev()->MemFree(mem);
-
- TEST_PASSED;
-}
-
-} // namespace
-
-void SetupTests() {
- RegisterTest("TestMemAllocAndMemFree", TestMemAllocAndMemFree);
-}
-
-void SetupPluginInterfaces() {
- // none
-}
diff --git a/ppapi/native_client/tests/ppapi_browser/ppb_memory/ppapi_ppb_memory.html b/ppapi/native_client/tests/ppapi_browser/ppb_memory/ppapi_ppb_memory.html
deleted file mode 100644
index bfd9a34..0000000
--- a/ppapi/native_client/tests/ppapi_browser/ppb_memory/ppapi_ppb_memory.html
+++ /dev/null
@@ -1,66 +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="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.
- // TODO(dmichael, polina, ncbray or mball): This is copy/pasted from
- // ppapi_ppb_instance.html, which was probably copy/pasted from
- // somewhere else. We should move this or something like it to
- // nacltest.js and remove this code from the tests that use it.
- 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('TestMemAllocAndMemFree');
- }
- //]]>
- </script>
- <title>PPAPI PPB_Memory_Dev Test</title>
- </head>
- <body>
- <h1>PPAPI PPB_Memory_Dev Test</h1>
-
- <embed type="application/x-nacl" id="test_nexe"
- name="nacl_module"
- src="ppapi_ppb_memory.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/ppb_url_loader/nacl.scons b/ppapi/native_client/tests/ppapi_browser/ppb_url_loader/nacl.scons
deleted file mode 100644
index 5957cd6..0000000
--- a/ppapi/native_client/tests/ppapi_browser/ppb_url_loader/nacl.scons
+++ /dev/null
@@ -1,44 +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_url_loader')
-
-nexe = env.ProgramNameForNmf('ppapi_ppb_url_loader')
-env.Alias('ppapi_ppb_url_loader${PROGSUFFIX}',
- ['$STAGING_DIR/%s${PROGSUFFIX}' % nexe])
-
-env.ComponentProgram(nexe,
- ['ppapi_ppb_url_loader.cc'],
- EXTRA_LIBS=['ppapi',
- 'ppapi_test_lib',
- 'platform',
- 'pthread',
- 'gio'])
-
-env.Publish(nexe, 'run',
- ['ppapi_ppb_url_loader.html',
- 'ppapi_ppb_url_loader.js',
- 'ppapi_ppb_url_loader.txt'])
-
-node = env.PPAPIBrowserTester('ppapi_ppb_url_loader_browser_test.out',
- url='ppapi_ppb_url_loader.html',
- nmf_names=['ppapi_ppb_url_loader'],
- files=env.ExtractPublishedFiles(nexe),
- args=['--allow_404',
- '--redirect_url',
- '/redirect-to-existing.txt',
- '/ppapi_ppb_url_loader.txt'],
- browser_flags=['--enable-pepper-testing'])
-
-env.AddNodeToTestSuite(node,
- ['chrome_browser_tests'],
- 'run_ppapi_ppb_url_loader_browser_test',
- is_broken=env.PPAPIBrowserTesterIsBroken())
diff --git a/ppapi/native_client/tests/ppapi_browser/ppb_url_loader/ppapi_ppb_url_loader.cc b/ppapi/native_client/tests/ppapi_browser/ppb_url_loader/ppapi_ppb_url_loader.cc
deleted file mode 100644
index 70d4d93..0000000
--- a/ppapi/native_client/tests/ppapi_browser/ppb_url_loader/ppapi_ppb_url_loader.cc
+++ /dev/null
@@ -1,822 +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 "native_client/src/include/nacl_scoped_ptr.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_stdint.h"
-#include "ppapi/c/pp_var.h"
-#include "ppapi/c/ppb_core.h"
-#include "ppapi/c/ppb_file_io.h"
-#include "ppapi/c/ppb_url_loader.h"
-#include "ppapi/c/ppb_url_request_info.h"
-#include "ppapi/c/ppb_url_response_info.h"
-#include "ppapi/c/ppb_var.h"
-
-#include "native_client/tests/ppapi_test_lib/get_browser_interface.h"
-#include "native_client/tests/ppapi_test_lib/test_interface.h"
-#include "native_client/tests/ppapi_test_lib/testable_callback.h"
-
-namespace {
-
-// Same content as file kExistingURL in this directory.
-const char* kContentsOfExistingURL = "Lorem ipsum dolor sit.\n";
-const char* kNonExistingURL = "does_not_exist";
-const char* kExistingURL = "ppapi_ppb_url_loader.txt";
-const char* kRedirectURL = "redirect-to-existing.txt";
-const char* kNoHeaders = NULL;
-
-const PP_Bool kStreamToFile = PP_TRUE;
-const PP_Bool kDontStreamToFile = PP_FALSE;
-
-const PP_Bool kDownloadProgress = PP_TRUE;
-const PP_Bool kNoDownloadProgress = PP_FALSE;
-
-const PP_Bool kFollowRedirects = PP_TRUE;
-const PP_Bool kDontFollowRedirects = PP_FALSE;
-
-// Helper functions, these are candidates for being moved to a helper_lib
-void CheckResponse(PP_Resource response,
- int http_status,
- const char* status_line,
- const char* response_url,
- const char* headers) {
- PP_Var var;
- var = PPBURLResponseInfo()->GetProperty(
- response, PP_URLRESPONSEPROPERTY_STATUSCODE);
- EXPECT_VAR_INT(var, http_status);
-
- if (status_line != NULL) {
- var = PPBURLResponseInfo()->GetProperty(
- response, PP_URLRESPONSEPROPERTY_STATUSLINE);
- EXPECT_VAR_STRING(var, status_line);
- PPBVar()->Release(var);
- }
-
- if (response_url != NULL) {
- // TODO(robertm): This needs a regexp pass to get rid of the port number
- // which is non-deterministic.
- var = PPBURLResponseInfo()->GetProperty(
- response, PP_URLRESPONSEPROPERTY_URL);
- EXPECT_VAR_STRING(var, response_url);
- PPBVar()->Release(var);
- }
-
- if (headers != NULL) {
- // TODO(robertm): This needs a regexp pass to get rid of the date, etc
- // which are non-deterministic.
- var = PPBURLResponseInfo()->GetProperty(
- response, PP_URLRESPONSEPROPERTY_HEADERS);
- EXPECT_VAR_STRING(var, headers);
- PPBVar()->Release(var);
- }
-}
-
-
-PP_Resource MakeRequest(const char* url,
- const char* method,
- const char* headers,
- PP_Bool to_file,
- PP_Bool download_progress,
- PP_Bool follow_redirects) {
- PP_Resource request = PPBURLRequestInfo()->Create(pp_instance());
- EXPECT(request != kInvalidResource);
- PP_Var var;
-
- if (url != NULL) {
- var = PP_MakeString(url);
- EXPECT(PP_TRUE == PPBURLRequestInfo()->SetProperty(
- request, PP_URLREQUESTPROPERTY_URL, var));
- PPBVar()->Release(var);
- }
-
- if (method != NULL) {
- var = PP_MakeString(method);
- EXPECT(PP_TRUE == PPBURLRequestInfo()->SetProperty(
- request, PP_URLREQUESTPROPERTY_METHOD, var));
- PPBVar()->Release(var);
- }
-
- if (headers != NULL) {
- var = PP_MakeString(method);
- EXPECT(PP_TRUE == PPBURLRequestInfo()->SetProperty(
- request, PP_URLREQUESTPROPERTY_HEADERS, var));
- PPBVar()->Release(var);
- }
-
- var = PP_MakeBool(to_file);
- EXPECT(PP_TRUE == PPBURLRequestInfo()->SetProperty(
- request, PP_URLREQUESTPROPERTY_STREAMTOFILE, var));
-
- var = PP_MakeBool(download_progress);
- EXPECT(PP_TRUE == PPBURLRequestInfo()->SetProperty(
- request, PP_URLREQUESTPROPERTY_RECORDDOWNLOADPROGRESS, var));
-
- var = PP_MakeBool(follow_redirects);
- EXPECT(PP_TRUE == PPBURLRequestInfo()->SetProperty(
- request, PP_URLREQUESTPROPERTY_FOLLOWREDIRECTS, var));
- return request;
-}
-
-PP_Resource MakeDummyRequest() {
- return MakeRequest(kNonExistingURL,
- "GET",
- kNoHeaders,
- kDontStreamToFile,
- kDownloadProgress,
- kFollowRedirects);
-}
-
-
-int32_t ReadAndVerify(bool is_file_io,
- PP_Resource resource,
- int offset,
- int buffer_size,
- const nacl::string& expected) {
- nacl::scoped_array<char> buffer(new char[buffer_size]);
- TestableCallback callback(pp_instance(), true);
- nacl::string actual;
- int32_t rv;
- for (;;) {
- callback.Reset();
- if (is_file_io) {
- rv = PPBFileIO()->Read(resource,
- offset + actual.size(),
- buffer.get(),
- buffer_size,
- callback.GetCallback());
- } else {
- rv = PPBURLLoader()->ReadResponseBody(
- resource, buffer.get(), buffer_size, callback.GetCallback());
- }
- EXPECT(PP_OK_COMPLETIONPENDING == rv);
- rv = callback.WaitForResult();
- if (rv == 0) {
- break;
- } else if (rv < 0) {
- return rv;
- } else {
- actual.append(buffer.get(), rv);
- }
- }
-
- // rv was zero
- EXPECT(actual == expected);
- return 0;
-}
-
-
-int32_t ReadAndVerifyResponseBody(PP_Resource loader,
- int buffer_size,
- const nacl::string& expected) {
- return ReadAndVerify(false, loader, 0, buffer_size, expected);
-}
-
-
-int32_t ReadAndVerifyFileContents(PP_Resource file_io,
- int offset,
- int buffer_size,
- const nacl::string& expected) {
- return ReadAndVerify(true, file_io, offset, buffer_size, expected);
-}
-
-
-void TestOpenSuccess() {
- int32_t rv;
- TestableCallback callback(pp_instance(), true);
- PP_Resource loader;
- PP_Resource response;
- PP_Resource request = MakeRequest(kExistingURL, "GET", kNoHeaders,
- kDontStreamToFile,
- kDownloadProgress,
- kFollowRedirects);
-
- LOG_TO_BROWSER("open and read entire existing file (all at once)");
- callback.Reset();
- loader = PPBURLLoader()->Create(pp_instance());
- rv = PPBURLLoader()->Open(loader, request, callback.GetCallback());
- EXPECT(PP_OK_COMPLETIONPENDING == rv);
- rv = callback.WaitForResult();
- EXPECT(PP_OK == rv);
- response = PPBURLLoader()->GetResponseInfo(loader);
- CheckResponse(response, 200, "OK", NULL, NULL);
- ReadAndVerifyResponseBody(loader, 1024, kContentsOfExistingURL);
- PPBCore()->ReleaseResource(loader);
-
- LOG_TO_BROWSER("open and read entire existing file (one byte at a time)");
- callback.Reset();
- loader = PPBURLLoader()->Create(pp_instance());
- rv = PPBURLLoader()->Open(loader, request, callback.GetCallback());
- EXPECT(PP_OK_COMPLETIONPENDING == rv);
- rv = callback.WaitForResult();
- EXPECT(PP_OK == rv);
- response = PPBURLLoader()->GetResponseInfo(loader);
- CheckResponse(response, 200, "OK", NULL, NULL);
- ReadAndVerifyResponseBody(loader, 1, kContentsOfExistingURL);
- PPBCore()->ReleaseResource(loader);
-
- PPBCore()->ReleaseResource(request);
-
- TEST_PASSED;
-}
-
-
-void TestOpenRedirect() {
- int32_t rv;
- TestableCallback callback(pp_instance(), true);
- PP_Resource loader;
- PP_Resource response;
- PP_Resource request_no_redirect = MakeRequest(kRedirectURL, "GET", kNoHeaders,
- kDontStreamToFile,
- kDownloadProgress,
- kDontFollowRedirects);
- PP_Resource request_redirect = MakeRequest(kRedirectURL, "GET", kNoHeaders,
- kDontStreamToFile,
- kDownloadProgress,
- kFollowRedirects);
-
- LOG_TO_BROWSER("redirect do NOT follow");
- callback.Reset();
- loader = PPBURLLoader()->Create(pp_instance());
- rv = PPBURLLoader()->Open(
- loader, request_no_redirect, callback.GetCallback());
- EXPECT(PP_OK_COMPLETIONPENDING == rv);
- rv = callback.WaitForResult();
- EXPECT(PP_OK == rv);
- response = PPBURLLoader()->GetResponseInfo(loader);
- CheckResponse(response, 301, "Moved", NULL, NULL);
- PPBCore()->ReleaseResource(loader);
-
- LOG_TO_BROWSER("redirect follow");
- callback.Reset();
- loader = PPBURLLoader()->Create(pp_instance());
- rv = PPBURLLoader()->Open(loader, request_redirect, callback.GetCallback());
- EXPECT(PP_OK_COMPLETIONPENDING == rv);
- rv = callback.WaitForResult();
- EXPECT(PP_OK == rv);
- response = PPBURLLoader()->GetResponseInfo(loader);
- CheckResponse(response, 200, "OK", NULL, NULL);
- // TODO(robertm): also try smaller sizes, e.g. one and zero
- EXPECT(PP_OK ==
- ReadAndVerifyResponseBody(loader, 1024, kContentsOfExistingURL));
-
- PPBCore()->ReleaseResource(loader);
- PPBCore()->ReleaseResource(request_redirect);
- PPBCore()->ReleaseResource(request_no_redirect);
-
- TEST_PASSED;
-}
-
-
-void TestOpenFailure() {
- int32_t rv;
- TestableCallback callback(pp_instance(), true);
- PP_Resource request = MakeDummyRequest();
- PP_Resource loader = PPBURLLoader()->Create(pp_instance());
-
- LOG_TO_BROWSER("open with non existing url");
- callback.Reset();
- rv = PPBURLLoader()->Open(loader, request, callback.GetCallback());
- EXPECT(PP_OK_COMPLETIONPENDING == rv);
- rv = callback.WaitForResult();
- EXPECT(PP_OK == rv);
-
- PP_Resource response = PPBURLLoader()->GetResponseInfo(loader);
- CheckResponse(response, 404, "File not found", NULL, NULL);
-
- PPBCore()->ReleaseResource(request);
- PPBCore()->ReleaseResource(loader);
-
- TEST_PASSED;
-}
-
-
-void TestStreamToFile() {
- int32_t rv;
- TestableCallback callback(pp_instance(), true);
- PP_Resource loader;
- PP_Resource file_ref;
- PP_Resource response;
- PP_Resource file_io;
- PP_Resource request = MakeRequest(kExistingURL, "GET", kNoHeaders,
- kStreamToFile,
- kDownloadProgress,
- kFollowRedirects);
-
- callback.Reset();
- loader = PPBURLLoader()->Create(pp_instance());
- rv = PPBURLLoader()->Open(loader, request, callback.GetCallback());
- EXPECT(PP_OK_COMPLETIONPENDING == rv);
- rv = callback.WaitForResult();
- EXPECT(PP_OK == rv);
-
- response = PPBURLLoader()->GetResponseInfo(loader);
- CheckResponse(response, 200, "OK", NULL, NULL);
-
- file_ref = PPBURLResponseInfo()->GetBodyAsFileRef(response);
- callback.Reset();
- rv = PPBURLLoader()->FinishStreamingToFile(loader, callback.GetCallback());
- EXPECT(PP_OK_COMPLETIONPENDING == rv);
- rv = callback.WaitForResult();
- EXPECT(PP_OK == rv);
-
- callback.Reset();
- file_io = PPBFileIO()->Create(pp_instance());
- rv = PPBFileIO()->Open(
- file_io, file_ref, PP_FILEOPENFLAG_READ, callback.GetCallback());
- EXPECT(PP_OK_COMPLETIONPENDING == rv);
- rv = callback.WaitForResult();
- EXPECT(PP_OK == rv);
-
- // TODO(robertm): add tests with different buffer sizes
- ReadAndVerifyFileContents(file_io, 0, 1024, kContentsOfExistingURL);
-
- PPBCore()->ReleaseResource(file_io);
- PPBCore()->ReleaseResource(file_ref);
- PPBCore()->ReleaseResource(response);
- PPBCore()->ReleaseResource(loader);
- PPBCore()->ReleaseResource(request);
-
- TEST_PASSED;
-}
-
-
-void TestOpenSimple() {
- int32_t rv;
- TestableCallback callback(pp_instance(), true);
- PP_Resource request = MakeDummyRequest();
- PP_Resource loader;
-
- LOG_TO_BROWSER("open with loader/request invalid");
- callback.Reset();
- rv = PPBURLLoader()->Open(
- kInvalidResource, kInvalidResource, callback.GetCallback());
- EXPECT(PP_OK_COMPLETIONPENDING == rv);
- rv = callback.WaitForResult();
- EXPECT(PP_ERROR_BADRESOURCE == rv);
- callback.Reset();
- rv = PPBURLLoader()->Open(
- kNotAResource, kNotAResource, callback.GetCallback());
- EXPECT(PP_OK_COMPLETIONPENDING == rv);
- rv = callback.WaitForResult();
- EXPECT(PP_ERROR_BADRESOURCE == rv);
-
- LOG_TO_BROWSER("open with loader invalid");
- callback.Reset();
- rv = PPBURLLoader()->Open(kInvalidResource, request, callback.GetCallback());
- EXPECT(PP_OK_COMPLETIONPENDING == rv);
- rv = callback.WaitForResult();
- EXPECT(PP_ERROR_BADRESOURCE == rv);
- callback.Reset();
- rv = PPBURLLoader()->Open(kNotAResource, request, callback.GetCallback());
- EXPECT(PP_OK_COMPLETIONPENDING == rv);
- rv = callback.WaitForResult();
- EXPECT(PP_ERROR_BADRESOURCE == rv);
- callback.Reset();
- rv = PPBURLLoader()->Open(request, request, callback.GetCallback());
- EXPECT(PP_OK_COMPLETIONPENDING == rv);
- rv = callback.WaitForResult();
- EXPECT(PP_ERROR_BADRESOURCE == rv);
-
- LOG_TO_BROWSER("open with request invalid");
- loader = PPBURLLoader()->Create(pp_instance());
- callback.Reset();
- rv = PPBURLLoader()->Open(loader, kInvalidResource, callback.GetCallback());
- EXPECT(PP_OK_COMPLETIONPENDING == rv);
- rv = callback.WaitForResult();
- EXPECT(PP_ERROR_BADARGUMENT == rv);
- callback.Reset();
- rv = PPBURLLoader()->Open(loader, kNotAResource, callback.GetCallback());
- EXPECT(PP_OK_COMPLETIONPENDING == rv);
- rv = callback.WaitForResult();
- EXPECT(PP_ERROR_BADARGUMENT == rv);
- callback.Reset();
- rv = PPBURLLoader()->Open(loader, loader, callback.GetCallback());
- EXPECT(PP_OK_COMPLETIONPENDING == rv);
- rv = callback.WaitForResult();
- EXPECT(PP_ERROR_BADARGUMENT == rv);
- PPBCore()->ReleaseResource(loader);
-
- LOG_TO_BROWSER("open (synchronous) with blocking callback on main thread");
- loader = PPBURLLoader()->Create(pp_instance());
- // We are on the main thread, performing a sync call should fail
- rv = PPBURLLoader()->Open(loader, request, PP_BlockUntilComplete());
- EXPECT(PP_ERROR_BLOCKS_MAIN_THREAD == rv);
- PPBCore()->ReleaseResource(loader);
-
- LOG_TO_BROWSER("open (asynchronous) normal");
- loader = PPBURLLoader()->Create(pp_instance());
- callback.Reset();
- rv = PPBURLLoader()->Open(loader, request, callback.GetCallback());
- EXPECT(PP_OK_COMPLETIONPENDING == rv);
- rv = callback.WaitForResult();
- EXPECT(PP_OK == rv);
- PPBCore()->ReleaseResource(loader);
-
- LOG_TO_BROWSER("open with with released loader");
- loader = PPBURLLoader()->Create(pp_instance());
- PPBCore()->ReleaseResource(loader);
- callback.Reset();
- rv = PPBURLLoader()->Open(loader, request, callback.GetCallback());
- EXPECT(PP_OK_COMPLETIONPENDING == rv);
- rv = callback.WaitForResult();
- EXPECT(PP_ERROR_BADRESOURCE == rv);
-
- PPBCore()->ReleaseResource(request);
-
- TEST_PASSED;
-}
-
-
-void TestDoubleOpen() {
- int32_t rv;
- PP_Resource loader;
- TestableCallback callback(pp_instance(), true);
- PP_Resource request1 = MakeRequest(kExistingURL, "GET", kNoHeaders,
- kDontStreamToFile,
- kDownloadProgress,
- kDontFollowRedirects);
- PP_Resource request2 = MakeRequest(kNonExistingURL, "GET", kNoHeaders,
- kDontStreamToFile,
- kDownloadProgress,
- kDontFollowRedirects);
-
- LOG_TO_BROWSER("open two requests on the same loader without Close");
- loader = PPBURLLoader()->Create(pp_instance());
- callback.Reset();
- rv = PPBURLLoader()->Open(loader, request1, callback.GetCallback());
- EXPECT(PP_OK_COMPLETIONPENDING == rv);
- rv = callback.WaitForResult();
- EXPECT(PP_OK == rv);
-
- callback.Reset();
- rv = PPBURLLoader()->Open(loader, request2, callback.GetCallback());
- EXPECT(PP_OK_COMPLETIONPENDING == rv);
- rv = callback.WaitForResult();
- EXPECT(PP_ERROR_INPROGRESS == rv);
- PPBCore()->ReleaseResource(loader);
-
- LOG_TO_BROWSER("open two requests on the same loader with Close");
- // NOTE: using Close should NOT make a difference either
- loader = PPBURLLoader()->Create(pp_instance());
- callback.Reset();
- rv = PPBURLLoader()->Open(loader, request1, callback.GetCallback());
- EXPECT(PP_OK_COMPLETIONPENDING == rv);
- rv = callback.WaitForResult();
- EXPECT(PP_OK == rv);
-
- PPBURLLoader()->Close(loader);
-
- callback.Reset();
- rv = PPBURLLoader()->Open(loader, request2, callback.GetCallback());
- EXPECT(PP_OK_COMPLETIONPENDING == rv);
- rv = callback.WaitForResult();
- EXPECT(PP_ERROR_INPROGRESS == rv);
- PPBCore()->ReleaseResource(loader);
-
- PPBCore()->ReleaseResource(request1);
- PPBCore()->ReleaseResource(request2);
-
- TEST_PASSED;
-}
-
-
-void TestProgressSimple() {
- int32_t rv;
- int64_t received;
- int64_t total;
- TestableCallback callback(pp_instance(), true);
- PP_Resource loader;
- PP_Resource req_bad = MakeDummyRequest();
- PP_Resource req_good = MakeRequest(kExistingURL, "GET", kNoHeaders,
- kDontStreamToFile,
- kDownloadProgress,
- kDontFollowRedirects);
- PP_Resource req_good_no_progress = MakeRequest(kExistingURL,
- "GET",
- kNoHeaders,
- kDontStreamToFile,
- kNoDownloadProgress,
- kDontFollowRedirects);
-
- LOG_TO_BROWSER("progress on invalid loader");
- rv = PPBURLLoader()->GetDownloadProgress(kInvalidResource, &received, &total);
- EXPECT(PP_FALSE == rv);
- rv = PPBURLLoader()->GetDownloadProgress(kNotAResource, &received, &total);
- EXPECT(PP_FALSE == rv);
- rv = PPBURLLoader()->GetDownloadProgress(req_bad, &received, &total);
- EXPECT(PP_FALSE == rv);
-
- LOG_TO_BROWSER("progress for failed request");
- callback.Reset();
- loader = PPBURLLoader()->Create(pp_instance());
- rv = PPBURLLoader()->Open(loader, req_bad, callback.GetCallback());
- EXPECT(PP_OK_COMPLETIONPENDING == rv);
- rv = callback.WaitForResult();
- EXPECT(PP_OK == rv);
- rv = PPBURLLoader()->GetDownloadProgress(loader, &received, &total);
- EXPECT(PP_TRUE == rv);
- PPBCore()->ReleaseResource(loader);
-
- LOG_TO_BROWSER("progress for request");
- callback.Reset();
- loader = PPBURLLoader()->Create(pp_instance());
- rv = PPBURLLoader()->Open(loader, req_good, callback.GetCallback());
- EXPECT(PP_OK_COMPLETIONPENDING == rv);
- rv = callback.WaitForResult();
- EXPECT(PP_OK == rv);
- rv = PPBURLLoader()->GetDownloadProgress(loader, &received, &total);
- EXPECT(PP_TRUE == rv);
- const int num_bytes_expected = strlen(kContentsOfExistingURL);
- EXPECT(total == num_bytes_expected);
- ReadAndVerifyResponseBody(loader, 1024, kContentsOfExistingURL);
- rv = PPBURLLoader()->GetDownloadProgress(loader, &received, &total);
- EXPECT(PP_TRUE == rv);
- EXPECT(total == num_bytes_expected);
- EXPECT(received == num_bytes_expected);
-
- PPBCore()->ReleaseResource(loader);
-
- LOG_TO_BROWSER("progress for request 'without progress'");
- callback.Reset();
- loader = PPBURLLoader()->Create(pp_instance());
- rv = PPBURLLoader()->Open(
- loader, req_good_no_progress, callback.GetCallback());
- EXPECT(PP_OK_COMPLETIONPENDING == rv);
- rv = callback.WaitForResult();
- EXPECT(PP_OK == rv);
- rv = PPBURLLoader()->GetDownloadProgress(loader, &received, &total);
- EXPECT(PP_FALSE == rv);
- PPBCore()->ReleaseResource(loader);
-
- PPBCore()->ReleaseResource(req_bad);
- PPBCore()->ReleaseResource(req_good);
- PPBCore()->ReleaseResource(req_good_no_progress);
-
- TEST_PASSED;
-}
-
-
-void TestResponseInfoSimple() {
- PP_Resource response;
- PP_Resource request = MakeDummyRequest();
-
- LOG_TO_BROWSER("response info on invalid loader");
- response = PPBURLLoader()->GetResponseInfo(kInvalidResource);
- EXPECT(kInvalidResource == response);
- response = PPBURLLoader()->GetResponseInfo(kNotAResource);
- EXPECT(kInvalidResource == response);
- response = PPBURLLoader()->GetResponseInfo(request);
- EXPECT(kInvalidResource == response);
-
- LOG_TO_BROWSER("response info without open");
- PP_Resource loader = PPBURLLoader()->Create(pp_instance());
- response = PPBURLLoader()->GetResponseInfo(loader);
- EXPECT(kInvalidResource == response);
- PPBCore()->ReleaseResource(loader);
-
- PPBCore()->ReleaseResource(request);
-
- TEST_PASSED;
-}
-
-
-void TestCloseSimple() {
- PP_Resource request = MakeDummyRequest();
- LOG_TO_BROWSER("close on invalid loader");
- // we just make sure we do not crash here.
- PPBURLLoader()->Close(kInvalidResource);
- PPBURLLoader()->Close(kNotAResource);
- PPBURLLoader()->Close(request);
-
- PPBCore()->ReleaseResource(request);
-
- TEST_PASSED;
-}
-
-
-void TestReadSimple() {
- int32_t rv;
- char buffer[1024];
- PP_Resource loader;
- TestableCallback callback(pp_instance(), true);
-
- PP_Resource request = MakeDummyRequest();
-
- LOG_TO_BROWSER("read on invalid loader");
- callback.Reset();
- rv = PPBURLLoader()->ReadResponseBody(
- kInvalidResource, buffer, sizeof buffer, callback.GetCallback());
- EXPECT(PP_OK_COMPLETIONPENDING == rv);
- rv = callback.WaitForResult();
- EXPECT(PP_ERROR_BADRESOURCE == rv);
-
- callback.Reset();
- rv = PPBURLLoader()->ReadResponseBody(
- kNotAResource, buffer, sizeof buffer, callback.GetCallback());
- EXPECT(PP_OK_COMPLETIONPENDING == rv);
- rv = callback.WaitForResult();
- EXPECT(PP_ERROR_BADRESOURCE == rv);
-
- callback.Reset();
- rv = PPBURLLoader()->ReadResponseBody(
- request, buffer, sizeof buffer, callback.GetCallback());
- EXPECT(PP_OK_COMPLETIONPENDING == rv);
- rv = callback.WaitForResult();
- EXPECT(PP_ERROR_BADRESOURCE == rv);
-
- LOG_TO_BROWSER("read without open");
- loader = PPBURLLoader()->Create(pp_instance());
- callback.Reset();
- rv = PPBURLLoader()->ReadResponseBody(
- loader, buffer, sizeof buffer, callback.GetCallback());
- EXPECT(PP_OK_COMPLETIONPENDING == rv);
- rv = callback.WaitForResult();
- EXPECT(PP_ERROR_FAILED == rv);
- PPBCore()->ReleaseResource(loader);
-
- PPBCore()->ReleaseResource(request);
-
- TEST_PASSED;
-}
-
-
-void TestStreamToFileSimple() {
- int32_t rv;
- PP_Resource loader;
- TestableCallback callback(pp_instance(), true);
- PP_Resource request = MakeDummyRequest();
-
- LOG_TO_BROWSER("stream on invalid loader");
- callback.Reset();
- rv = PPBURLLoader()->FinishStreamingToFile(
- kInvalidResource, callback.GetCallback());
- EXPECT(PP_OK_COMPLETIONPENDING == rv);
- rv = callback.WaitForResult();
- EXPECT(PP_ERROR_BADRESOURCE == rv);
-
- callback.Reset();
- rv = PPBURLLoader()->FinishStreamingToFile(
- kNotAResource, callback.GetCallback());
- EXPECT(PP_OK_COMPLETIONPENDING == rv);
- rv = callback.WaitForResult();
- EXPECT(PP_ERROR_BADRESOURCE == rv);
-
- callback.Reset();
- rv = PPBURLLoader()->FinishStreamingToFile(
- request, callback.GetCallback());
- EXPECT(PP_OK_COMPLETIONPENDING == rv);
- rv = callback.WaitForResult();
- EXPECT(PP_ERROR_BADRESOURCE == rv);
-
- LOG_TO_BROWSER("stream without open");
- callback.Reset();
- loader = PPBURLLoader()->Create(pp_instance());
- rv = PPBURLLoader()->FinishStreamingToFile(
- loader, callback.GetCallback());
- EXPECT(PP_OK_COMPLETIONPENDING == rv);
- rv = callback.WaitForResult();
- EXPECT(PP_ERROR_FAILED == rv);
- PPBCore()->ReleaseResource(loader);
-
- PPBCore()->ReleaseResource(request);
-
- TEST_PASSED;
-}
-
-
-void TestAbort() {
- int32_t rv;
- PP_Resource loader;
- PP_Resource request = MakeRequest(kExistingURL, "GET", kNoHeaders,
- kDontStreamToFile,
- kDownloadProgress,
- kDontFollowRedirects);
- TestableCallback callback(pp_instance(), true);
-
- LOG_TO_BROWSER("release loader while open in flight");
- loader = PPBURLLoader()->Create(pp_instance());
- callback.Reset();
- rv = PPBURLLoader()->Open(loader, request, callback.GetCallback());
- EXPECT(PP_OK_COMPLETIONPENDING == rv);
- PPBCore()->ReleaseResource(loader);
- rv = callback.WaitForResult();
- EXPECT(PP_ERROR_ABORTED == rv);
- PPBCore()->ReleaseResource(loader);
-
- // TODO(sanga,polina): Investigate why this case is hanging
- // The problem is that the callback never gets called.
- // So WaitForResult() never returns.
- // This is also true for regular callback.
-#if 0
- LOG_TO_BROWSER("close loader while open in flight");
- loader = PPBURLLoader()->Create(pp_instance());
- callback.Reset();
- rv = PPBURLLoader()->Open(loader, request, callback.GetCallback());
- EXPECT(PP_OK_COMPLETIONPENDING == rv);
- PPBURLLoader()->Close(loader);
- rv = callback.WaitForResult();
- EXPECT(PP_ERROR_ABORTED == rv);
- PPBCore()->ReleaseResource(loader);
-#endif
-
- // NOTE: this should be last in this function since it releases the request
- LOG_TO_BROWSER("release request while open in flight");
- loader = PPBURLLoader()->Create(pp_instance());
- callback.Reset();
- rv = PPBURLLoader()->Open(loader, request, callback.GetCallback());
- EXPECT(PP_OK_COMPLETIONPENDING == rv);
- PPBCore()->ReleaseResource(request);
- rv = callback.WaitForResult();
- // loader holds another ref so this is ok
- EXPECT(PP_OK == rv);
- PPBCore()->ReleaseResource(loader);
-
- TEST_PASSED;
-}
-
-
-void TestOpenReadMismatch() {
- int32_t rv;
- char buffer[1024];
- TestableCallback callback(pp_instance(), true);
- PP_Resource loader;
- PP_Resource response;
- PP_Resource request_regular = MakeRequest(kExistingURL, "GET", kNoHeaders,
- kDontStreamToFile,
- kDownloadProgress,
- kFollowRedirects);
- PP_Resource request_stream = MakeRequest(kExistingURL, "GET", kNoHeaders,
- kStreamToFile,
- kDownloadProgress,
- kFollowRedirects);
-
- LOG_TO_BROWSER("open regularly but try streaming");
- callback.Reset();
- loader = PPBURLLoader()->Create(pp_instance());
- rv = PPBURLLoader()->Open(loader, request_regular, callback.GetCallback());
- EXPECT(PP_OK_COMPLETIONPENDING == rv);
- rv = callback.WaitForResult();
- EXPECT(PP_OK == rv);
- response = PPBURLLoader()->GetResponseInfo(loader);
- CheckResponse(response, 200, "OK", NULL, NULL);
- PP_Resource file_ref = PPBURLResponseInfo()->GetBodyAsFileRef(response);
- EXPECT(kInvalidResource == file_ref);
- PPBCore()->ReleaseResource(loader);
-
- LOG_TO_BROWSER("open as stream but read via ReadResponseBody");
- callback.Reset();
- loader = PPBURLLoader()->Create(pp_instance());
- rv = PPBURLLoader()->Open(loader, request_stream, callback.GetCallback());
- EXPECT(PP_OK_COMPLETIONPENDING == rv);
- rv = callback.WaitForResult();
- EXPECT(PP_OK == rv);
- response = PPBURLLoader()->GetResponseInfo(loader);
- CheckResponse(response, 200, "OK", NULL, NULL);
- rv = PPBURLLoader()->ReadResponseBody(
- loader, buffer, sizeof buffer, callback.GetCallback());
- EXPECT(PP_OK_COMPLETIONPENDING == rv);
- rv = callback.WaitForResult();
- EXPECT(PP_ERROR_FAILED == rv);
- PPBCore()->ReleaseResource(loader);
-
- PPBCore()->ReleaseResource(request_stream);
- PPBCore()->ReleaseResource(request_regular);
-
- TEST_PASSED;
-}
-
-} // namespace
-
-
-void SetupTests() {
- // This test requires PPBTestingDev()
- CHECK(PPBTestingDev() != NULL);
-
- // TODO(robertm): add POST tests
- RegisterTest("TestOpenSimple", TestOpenSimple);
- RegisterTest("TestStreamToFileSimple", TestStreamToFileSimple);
- RegisterTest("TestProgressSimple", TestProgressSimple);
- RegisterTest("TestResponseInfoSimple", TestResponseInfoSimple);
- RegisterTest("TestCloseSimple", TestCloseSimple);
- RegisterTest("TestReadSimple", TestReadSimple);
-
- RegisterTest("TestAbort", TestAbort);
- RegisterTest("TestDoubleOpen", TestDoubleOpen);
- RegisterTest("TestOpenSuccess", TestOpenSuccess);
- RegisterTest("TestOpenFailure", TestOpenFailure);
- RegisterTest("TestOpenRedirect", TestOpenRedirect);
- RegisterTest("TestOpenReadMismatch", TestOpenReadMismatch);
- RegisterTest("TestStreamToFile", TestStreamToFile);
-}
-
-
-void SetupPluginInterfaces() {
- // No PPP interface to test.
-}
diff --git a/ppapi/native_client/tests/ppapi_browser/ppb_url_loader/ppapi_ppb_url_loader.html b/ppapi/native_client/tests/ppapi_browser/ppb_url_loader/ppapi_ppb_url_loader.html
deleted file mode 100644
index 04a229e..0000000
--- a/ppapi/native_client/tests/ppapi_browser/ppb_url_loader/ppapi_ppb_url_loader.html
+++ /dev/null
@@ -1,29 +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="text/javascript" src="ppapi_ppb_url_loader.js"></script>
- <title>PPAPI PPB_UrlLoader Test</title>
- </head>
- <body>
- <h1>PPAPI PPB_UrlLoader Test</h1>
-
- <embed type="application/x-nacl" id="test_nexe"
- name="nacl_module"
- src="ppapi_ppb_url_loader.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/ppb_url_loader/ppapi_ppb_url_loader.js b/ppapi/native_client/tests/ppapi_browser/ppb_url_loader/ppapi_ppb_url_loader.js
deleted file mode 100644
index 2a50159..0000000
--- a/ppapi/native_client/tests/ppapi_browser/ppb_url_loader/ppapi_ppb_url_loader.js
+++ /dev/null
@@ -1,36 +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 setupTests(tester, plugin) {
- var kTests = ['TestStreamToFileSimple',
- 'TestProgressSimple',
- 'TestOpenSimple',
- 'TestResponseInfoSimple',
- 'TestCloseSimple',
- 'TestReadSimple',
-
- 'TestOpenReadMismatch',
- 'TestAbort',
- 'TestDoubleOpen',
- 'TestOpenSuccess',
- 'TestOpenRedirect',
- 'TestOpenFailure',
- 'TestStreamToFile',
- ];
-
-
- for (var i = 0; i < kTests.length; i++) {
- var name = kTests[i];
-
- // NOTE: closure semantics in JS will always use the
- // last value of "name".
- var f = function(n) {
- return function(test) {
- test.expectMessageSequence(plugin, [n +':PASSED']);
- plugin.postMessage(n);
- }} (name);
-
- tester.addAsyncTest(name, f);
- }
-}
diff --git a/ppapi/native_client/tests/ppapi_browser/ppb_url_loader/ppapi_ppb_url_loader.txt b/ppapi/native_client/tests/ppapi_browser/ppb_url_loader/ppapi_ppb_url_loader.txt
deleted file mode 100644
index 1cca58b..0000000
--- a/ppapi/native_client/tests/ppapi_browser/ppb_url_loader/ppapi_ppb_url_loader.txt
+++ /dev/null
@@ -1 +0,0 @@
-Lorem ipsum dolor sit.
diff --git a/ppapi/native_client/tests/ppapi_geturl/module.cc b/ppapi/native_client/tests/ppapi_geturl/module.cc
deleted file mode 100644
index 18ee82c..0000000
--- a/ppapi/native_client/tests/ppapi_geturl/module.cc
+++ /dev/null
@@ -1,277 +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/tests/ppapi_geturl/module.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <string>
-
-#include "native_client/src/include/nacl_macros.h"
-#include "native_client/src/include/portability.h"
-#include "native_client/src/shared/platform/nacl_check.h"
-#include "native_client/tests/ppapi_geturl/url_load_request.h"
-
-#include "ppapi/c/pp_completion_callback.h"
-#include "ppapi/c/pp_errors.h"
-#include "ppapi/c/pp_var.h"
-#include "ppapi/c/ppp_instance.h"
-#include "ppapi/c/ppp_messaging.h"
-
-namespace {
-
-// These constants need to match their corresponding JavaScript values in
-// ppapi_geturl.html. The JavaScript variables are all upper-case; for example
-// kTrueStringValue corresponds to TRUE_STRING_VALUE.
-const char* const kLoadUrlMethodId = "loadUrl";
-const char* const kTrueStringValue = "1";
-const char* const kFalseStringValue = "0";
-static const char kArgumentSeparator = '|';
-
-// A helper function to convert a bool to a string, used when assembling
-// messages posted back to the browser. |true| is converted to "1", |false| to
-// "0".
-const std::string BoolToString(bool bool_value) {
- return bool_value ? kTrueStringValue : kFalseStringValue;
-}
-
-PPP_Instance instance_interface;
-PPP_Messaging messaging_interface;
-Module* singleton_ = NULL;
-
-} // namespace
-
-PP_Bool Instance_DidCreate(PP_Instance /*pp_instance*/,
- uint32_t /*argc*/,
- const char* /*argn*/[],
- const char* /*argv*/[]) {
- printf("--- Instance_DidCreate\n");
- return PP_TRUE;
-}
-
-void Instance_DidDestroy(PP_Instance /*instance*/) {
- printf("--- Instance_DidDestroy\n");
-}
-
-void Instance_DidChangeView(PP_Instance /*pp_instance*/, PP_Resource /*view*/) {
-}
-
-void Instance_DidChangeFocus(PP_Instance /*pp_instance*/,
- PP_Bool /*has_focus*/) {
-}
-
-PP_Bool Instance_HandleDocumentLoad(PP_Instance /*pp_instance*/,
- PP_Resource /*pp_url_loader*/) {
- return PP_FALSE;
-}
-
-void Messaging_HandleMessage(PP_Instance instance, struct PP_Var var_message) {
- if (var_message.type != PP_VARTYPE_STRING)
- return;
- std::string message = Module::Get()->VarToStr(var_message);
- printf("--- Messaging_HandleMessage(%s)\n", message.c_str());
- // Look for the "loadUrl" message. The expected string format looks like:
- // loadUrl|<url>|<stream_as_file>
- // loadUrl is a string literal
- // <url> is the URL used to make the GET request in UrlLoader
- // <stream_as_file> represent Boolean true if it's a '1' or false if it's
- // anything else.
- if (message.find(kLoadUrlMethodId) != 0)
- return;
-
- size_t url_pos = message.find_first_of(kArgumentSeparator);
- if (url_pos == std::string::npos || url_pos + 1 >= message.length())
- return;
-
- size_t as_file_pos = message.find_first_of(kArgumentSeparator, url_pos + 1);
- if (as_file_pos == std::string::npos || as_file_pos + 1 >= message.length())
- return;
-
- size_t url_length = as_file_pos - url_pos;
- if (url_length == 0)
- return;
- std::string url = message.substr(url_pos + 1, url_length - 1);
-
- // If the second argument is a '1', assume it means |stream_as_file| is
- // true. Anything else means |stream_as_file| is false.
- bool stream_as_file = message.compare(as_file_pos + 1,
- 1,
- kTrueStringValue) == 0;
-
- printf("--- Messaging_HandleMessage(method='%s', "
- "url='%s', "
- "stream_as_file='%s')\n",
- message.c_str(),
- url.c_str(),
- stream_as_file ? "true" : "false");
- fflush(stdout);
-
- UrlLoadRequest* url_load_request = new UrlLoadRequest(instance);
- if (NULL == url_load_request) {
- Module::Get()->ReportResult(instance,
- url.c_str(),
- stream_as_file,
- "LoadUrl: memory allocation failed",
- false);
- return;
- }
- // On success or failure url_load_request will call ReportResult().
- // This is the time to clean it up.
- url_load_request->set_delete_this_after_report();
- url_load_request->Load(stream_as_file, url);
-}
-
-Module* Module::Create(PP_Module module_id,
- PPB_GetInterface get_browser_interface) {
- if (NULL == singleton_) {
- singleton_ = new Module(module_id, get_browser_interface);
- }
- return singleton_;
-}
-
-Module* Module::Get() {
- return singleton_;
-}
-
-void Module::Free() {
- delete singleton_;
- singleton_ = NULL;
-}
-
-Module::Module(PP_Module module_id, PPB_GetInterface get_browser_interface)
- : module_id_(module_id),
- get_browser_interface_(get_browser_interface),
- ppb_core_interface_(NULL),
- ppb_messaging_interface_(NULL),
- ppb_var_interface_(NULL) {
- printf("--- Module::Module\n");
- memset(&instance_interface, 0, sizeof(instance_interface));
- instance_interface.DidCreate = Instance_DidCreate;
- instance_interface.DidDestroy = Instance_DidDestroy;
- instance_interface.DidChangeView = Instance_DidChangeView;
- instance_interface.DidChangeFocus = Instance_DidChangeFocus;
- instance_interface.HandleDocumentLoad = Instance_HandleDocumentLoad;
-
- memset(&messaging_interface, 0, sizeof(messaging_interface));
- messaging_interface.HandleMessage = Messaging_HandleMessage;
-
- ppb_core_interface_ =
- static_cast<const PPB_Core*>(
- GetBrowserInterface(PPB_CORE_INTERFACE));
- ppb_messaging_interface_ =
- static_cast<const PPB_Messaging*>(
- GetBrowserInterface(PPB_MESSAGING_INTERFACE));
- ppb_var_interface_ =
- static_cast<const PPB_Var*>(
- GetBrowserInterface(PPB_VAR_INTERFACE));
-}
-
-const void* Module::GetPluginInterface(const char* interface_name) {
- printf("--- Module::GetPluginInterface(%s)\n", interface_name);
- if (strcmp(interface_name, PPP_INSTANCE_INTERFACE) == 0)
- return &instance_interface;
- if (strcmp(interface_name, PPP_MESSAGING_INTERFACE) == 0)
- return &messaging_interface;
- return NULL;
-}
-
-const void* Module::GetBrowserInterface(const char* interface_name) {
- if (NULL == get_browser_interface_)
- return NULL;
- return (*get_browser_interface_)(interface_name);
-}
-
-char* Module::VarToCStr(const PP_Var& var) {
- Module* module = Get();
- if (NULL == module)
- return NULL;
- const PPB_Var* ppb_var = module->ppb_var_interface();
- if (NULL == ppb_var)
- return NULL;
- uint32_t len = 0;
- const char* pp_str = ppb_var->VarToUtf8(var, &len);
- if (NULL == pp_str)
- return NULL;
- char* str = static_cast<char*>(malloc(len + 1));
- if (NULL == str)
- return NULL;
- memcpy(str, pp_str, len);
- str[len] = 0;
- return str;
-}
-
-std::string Module::VarToStr(const PP_Var& var) {
- std::string str;
- char* cstr = VarToCStr(var);
- if (NULL != cstr) {
- str = cstr;
- free(cstr);
- }
- return str;
-}
-
-PP_Var Module::StrToVar(const char* str) {
- Module* module = Get();
- if (NULL == module)
- return PP_MakeUndefined();
- const PPB_Var* ppb_var = module->ppb_var_interface();
- if (NULL != ppb_var)
- return ppb_var->VarFromUtf8(str, strlen(str));
- return PP_MakeUndefined();
-}
-
-PP_Var Module::StrToVar(const std::string& str) {
- return Module::StrToVar(str.c_str());
-}
-
-std::string Module::ErrorCodeToStr(int32_t error_code) {
- switch (error_code) {
- case PP_OK: return "PP_OK";
- case PP_OK_COMPLETIONPENDING: return "PP_OK_COMPLETIONPENDING";
- case PP_ERROR_FAILED: return "PP_ERROR_FAILED";
- case PP_ERROR_ABORTED: return "PP_ERROR_ABORTED";
- case PP_ERROR_BADARGUMENT: return "PP_ERROR_BADARGUMENT";
- case PP_ERROR_BADRESOURCE: return "PP_ERROR_BADRESOURCE";
- case PP_ERROR_NOINTERFACE: return "PP_ERROR_NOINTERFACE";
- case PP_ERROR_NOACCESS: return "PP_ERROR_NOACCESS";
- case PP_ERROR_NOMEMORY: return "PP_ERROR_NOMEMORY";
- case PP_ERROR_NOSPACE: return "PP_ERROR_NOSPACE";
- case PP_ERROR_NOQUOTA: return "PP_ERROR_NOQUOTA";
- case PP_ERROR_INPROGRESS: return "PP_ERROR_INPROGRESS";
- case PP_ERROR_FILENOTFOUND: return "PP_ERROR_FILENOTFOUND";
- case PP_ERROR_FILEEXISTS: return "PP_ERROR_FILEEXISTS";
- case PP_ERROR_FILETOOBIG: return "PP_ERROR_FILETOOBIG";
- case PP_ERROR_FILECHANGED: return "PP_ERROR_FILECHANGED";
- case PP_ERROR_TIMEDOUT: return "PP_ERROR_TIMEDOUT";
- }
- return "N/A";
-}
-
-void Module::ReportResult(PP_Instance pp_instance,
- const char* url,
- bool as_file,
- const char* text,
- bool success) {
- printf("--- ReportResult('%s', as_file=%d, '%s', success=%d)\n",
- url, as_file, text, success);
- // Post a message with the results back to the browser.
- std::string result(url);
- result += kArgumentSeparator;
- result += BoolToString(as_file);
- result += kArgumentSeparator;
- result += text;
- result += kArgumentSeparator;
- result += BoolToString(success);
- printf("--- ReportResult posts result string:\n\t%s\n", result.c_str());
- struct PP_Var var_result = StrToVar(result);
- ppb_messaging_interface()->PostMessage(pp_instance, var_result);
- // If the message was created using VarFromUtf8() it needs to be released.
- // See the comments about VarFromUtf8() in ppapi/c/ppb_var.h for more
- // information.
- if (var_result.type == PP_VARTYPE_STRING) {
- ppb_var_interface()->Release(var_result);
- }
-}
diff --git a/ppapi/native_client/tests/ppapi_geturl/module.h b/ppapi/native_client/tests/ppapi_geturl/module.h
deleted file mode 100644
index 3cc474a..0000000
--- a/ppapi/native_client/tests/ppapi_geturl/module.h
+++ /dev/null
@@ -1,62 +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.
-#ifndef TESTS_PPAPI_GETURL_MODULE_H_
-#define TESTS_PPAPI_GETURL_MODULE_H_
-
-#include <string>
-
-#include "ppapi/c/pp_module.h"
-#include "ppapi/c/pp_resource.h"
-#include "ppapi/c/ppb.h"
-#include "ppapi/c/ppb_core.h"
-#include "ppapi/c/ppb_messaging.h"
-#include "ppapi/c/ppb_var.h"
-#include "ppapi/c/ppp.h"
-
-// ppapi_geturl example is deliberately using C PPAPI interface.
-// C++ PPAPI layer has pp::Module wrapper class.
-class Module {
- public:
- static Module* Create(PP_Module module_id,
- PPB_GetInterface get_browser_interface);
- static Module* Get();
- static void Free();
-
- const void* GetPluginInterface(const char* interface_name);
- const void* GetBrowserInterface(const char* interface_name);
- PP_Module module_id() { return module_id_; }
- const PPB_Core* ppb_core_interface() const { return ppb_core_interface_; }
- const PPB_Messaging* ppb_messaging_interface() const {
- return ppb_messaging_interface_;
- }
- const PPB_Var* ppb_var_interface() const { return ppb_var_interface_; }
-
- static char* VarToCStr(const PP_Var& var);
- static std::string VarToStr(const PP_Var& var);
- static PP_Var StrToVar(const char* str);
- static PP_Var StrToVar(const std::string& str);
- static std::string ErrorCodeToStr(int32_t error_code);
-
- // Constructs a parameterized message string then uses messaging.PostMessage
- // to send this message back to the browser. The receiving message handler
- // is defined in ppapi_geturl.html
- void ReportResult(PP_Instance pp_instance,
- const char* url,
- bool as_file,
- const char* text,
- bool success);
- private:
- PP_Module module_id_;
- PPB_GetInterface get_browser_interface_;
- const PPB_Core* ppb_core_interface_;
- const PPB_Messaging* ppb_messaging_interface_;
- const PPB_Var* ppb_var_interface_;
-
- Module(PP_Module module_id, PPB_GetInterface get_browser_interface);
- ~Module() { }
- Module(const Module&);
- void operator=(const Module&);
-};
-
-#endif // TESTS_PPAPI_GETURL_MODULE_H_
diff --git a/ppapi/native_client/tests/ppapi_geturl/nacl.scons b/ppapi/native_client/tests/ppapi_geturl/nacl.scons
deleted file mode 100644
index dbbfbb8..0000000
--- a/ppapi/native_client/tests/ppapi_geturl/nacl.scons
+++ /dev/null
@@ -1,50 +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.
-
-# ppapi_geturl.html - test driver that loads the nexe and scripts it
-# ppapi_geturl_success.html - to be url-loaded and displayed w/n driver html
-#
-# ppapi_geturl.cc - implementation of PPP interface
-# module.h/cc - implementation of PPP_Instance interface
-# scriptable_object.h/cc - implementation of the scripting interface
-# url_load_request.h/cc - url loading helper
-
-Import('env')
-
-# http://code.google.com/p/nativeclient/issues/detail?id=2359
-if env.Bit('bitcode') and env.Bit('nacl_glibc'):
- Return()
-
-env.Prepend(CPPDEFINES=['XP_UNIX'])
-env.Replace(TEST_DIR='${SOURCE_ROOT}/ppapi/native_client/tests/' +
- 'ppapi_geturl/')
-
-nexe = env.ProgramNameForNmf('ppapi_geturl')
-env.Alias('ppapi_geturl${PROGSUFFIX}',
- ['$STAGING_DIR/%s${PROGSUFFIX}' % nexe])
-
-ppapi_geturl_nexe = env.ComponentProgram(nexe,
- ['module.cc',
- 'ppapi_geturl.cc',
- 'url_load_request.cc',
- ],
- EXTRA_LIBS=['ppapi',
- 'platform'])
-
-env.Publish(nexe, 'run',
- ['ppapi_geturl.html',
- 'ppapi_geturl_success.html'])
-
-node = env.PPAPIBrowserTester('ppapi_geturl_browser_test.out',
- url='ppapi_geturl.html',
- nmf_names=['ppapi_geturl'],
- files=env.ExtractPublishedFiles(nexe),
- args=['--allow_404'],
- )
-
-env.AddNodeToTestSuite(node,
- ['chrome_browser_tests'],
- 'run_ppapi_geturl_browser_test',
- is_broken=env.PPAPIBrowserTesterIsBroken())
diff --git a/ppapi/native_client/tests/ppapi_geturl/ppapi_geturl.cc b/ppapi/native_client/tests/ppapi_geturl/ppapi_geturl.cc
deleted file mode 100644
index e2209e4..0000000
--- a/ppapi/native_client/tests/ppapi_geturl/ppapi_geturl.cc
+++ /dev/null
@@ -1,39 +0,0 @@
-// 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 <cstdio>
-#include <cstdlib>
-
-#include "ppapi/c/pp_errors.h"
-#include "ppapi/c/ppb_instance.h"
-
-#include "native_client/tests/ppapi_geturl/module.h"
-
-// Global PPP functions --------------------------------------------------------
-
-PP_EXPORT int32_t PPP_InitializeModule(PP_Module module_id,
- PPB_GetInterface get_browser_interface) {
- printf("--- PPP_InitializeModule\n");
- fflush(stdout);
-
- Module* module = Module::Create(module_id, get_browser_interface);
- if (NULL == module)
- return PP_ERROR_FAILED;
- return PP_OK;
-}
-
-PP_EXPORT void PPP_ShutdownModule() {
- printf("--- PPP_ShutdownModule\n");
- fflush(stdout);
- Module::Free();
-}
-
-PP_EXPORT const void* PPP_GetInterface(const char* interface_name) {
- printf("--- PPP_GetInterface(%s)\n", interface_name);
- fflush(stdout);
- Module* module = Module::Get();
- if (NULL == module)
- return NULL;
- return module->GetPluginInterface(interface_name);
-}
diff --git a/ppapi/native_client/tests/ppapi_geturl/ppapi_geturl.html b/ppapi/native_client/tests/ppapi_geturl/ppapi_geturl.html
deleted file mode 100644
index db75192..0000000
--- a/ppapi/native_client/tests/ppapi_geturl/ppapi_geturl.html
+++ /dev/null
@@ -1,102 +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">
- //<![CDATA[
- // These constants need to match their corresponding values in module.cc.
- var ARGUMENT_SEPARATOR = '|';
- var TRUE_STRING_VALUE = '1';
- var FALSE_STRING_VALUE = '0';
-
- function isMatch(actual, expected) {
- return (0 <= actual.indexOf(expected));
- }
-
- // Convert a string to a boolean value. '1' convertes to |true|,
- // anything else converts to |false|.
- function stringToBool(str_value) {
- return str_value == TRUE_STRING_VALUE;
- }
-
- // Convert a boolean value to the corresponding string value. |true|
- // converts to '1', |false| to '0'.
- function boolToString(bool_value) {
- return bool_value ? TRUE_STRING_VALUE : FALSE_STRING_VALUE;
- }
-
- function setupTests(tester, plugin) {
- function addTest(name, url, as_file, expected_data, expected_success) {
- tester.addAsyncTest(name, function(test) {
- var listener = test.wrap(function(test_response) {
- plugin.removeEventListener('message', listener, false);
-
- var response_args =
- test_response.data.split(ARGUMENT_SEPARATOR);
- test.assertEqual(response_args.length, 4);
-
- // Validate the results.
- var response_url = response_args[0];
- var response_as_file = stringToBool(response_args[1]);
- var response_data = response_args[2];
- var response_success = stringToBool(response_args[3]);
- test.assert(isMatch(response_url, url));
- test.assertEqual(response_as_file, as_file);
- test.log(response_data);
- test.assert(isMatch(response_data, expected_data));
- test.assertEqual(response_success, expected_success);
- test.pass();
- });
- plugin.addEventListener('message', listener, false);
-
- // Make the request.
- var loadUrlMessage = [
- 'loadUrl',
- url,
- boolToString(as_file)].join(ARGUMENT_SEPARATOR);
- plugin.postMessage(loadUrlMessage);
- });
- }
-
- var VALID_URL = 'ppapi_geturl_success.html';
- var CROSSORIGIN_URL = 'http://www.google.com/robots.txt';
- var INVALID_URL = 'ppapi_nonexistent_url.html';
-
- addTest('Valid', VALID_URL, false, 'TEST PASSED', true);
- addTest('Valid_File', VALID_URL, true, 'TEST PASSED', true);
- addTest('CrossOrigin', CROSSORIGIN_URL, false, 'PP_ERROR_NOACCESS',
- false);
- addTest('CrossOrigin_File', CROSSORIGIN_URL, true, 'PP_ERROR_NOACCESS',
- false);
- addTest('Invalid', INVALID_URL, false, '404', false);
- addTest('Invalid_File', INVALID_URL, true, '404', false);
- }
- //]]>
- </script>
-
- <title>PPAPI GetURL Test</title>
- </head>
- <body>
- <h1>PPAPI GetURL Test</h1>
-
- <embed type="application/x-nacl"
- id="nacl"
- name="nacl_module"
- src="ppapi_geturl.nmf"
- width="0" height="0" />
-
- <script type="text/javascript">
- //<![CDATA[
- // TODO(ncbray) allow the test to run in parallel
- var tester = new Tester();
- setupTests(tester, $('nacl'));
- tester.waitFor($('nacl'));
- tester.run();
- //]]>
- </script>
- </body>
-</html>
diff --git a/ppapi/native_client/tests/ppapi_geturl/ppapi_geturl_success.html b/ppapi/native_client/tests/ppapi_geturl/ppapi_geturl_success.html
deleted file mode 100644
index 0bda3ee..0000000
--- a/ppapi/native_client/tests/ppapi_geturl/ppapi_geturl_success.html
+++ /dev/null
@@ -1,5 +0,0 @@
-TEST PASSED
- The test code searches for the above string
- in this file to ensure that the file was loaded.
- If you are seeing the contents of this page as part of the test output,
- then the test passed.
diff --git a/ppapi/native_client/tests/ppapi_geturl/url_load_request.cc b/ppapi/native_client/tests/ppapi_geturl/url_load_request.cc
deleted file mode 100644
index a53b78f..0000000
--- a/ppapi/native_client/tests/ppapi_geturl/url_load_request.cc
+++ /dev/null
@@ -1,350 +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/tests/ppapi_geturl/url_load_request.h"
-
-#include <stdio.h>
-#include <string>
-#include <sstream>
-
-#include "native_client/src/include/portability.h"
-#include "native_client/src/include/nacl_macros.h"
-#include "native_client/src/shared/platform/nacl_check.h"
-#include "native_client/tests/ppapi_geturl/module.h"
-#include "ppapi/c/pp_bool.h"
-#include "ppapi/c/pp_completion_callback.h"
-#include "ppapi/c/pp_errors.h"
-
-namespace {
-
-// A local helper that does not contribute to loading/reading of urls, but
-// allows us to test proxying of Is<Interface> functions.
-// TODO(polina): when we have unit tests, move this there.
-void TestIsInterface(std::string test_interface,
- PP_Resource resource,
- const PPB_FileIO* ppb_fileio,
- const PPB_URLRequestInfo* ppb_url_request_info,
- const PPB_URLResponseInfo* ppb_url_response_info,
- const PPB_URLLoader* ppb_url_loader) {
- printf("--- TestIsInterface: %s\n", test_interface.c_str());
- if (test_interface == PPB_FILEIO_INTERFACE) {
- CHECK(ppb_fileio->IsFileIO(resource) == PP_TRUE);
- CHECK(ppb_url_request_info->IsURLRequestInfo(resource) == PP_FALSE);
- CHECK(ppb_url_response_info->IsURLResponseInfo(resource) == PP_FALSE);
- CHECK(ppb_url_loader->IsURLLoader(resource) == PP_FALSE);
- } else if (test_interface == PPB_URLREQUESTINFO_INTERFACE) {
- CHECK(ppb_fileio->IsFileIO(resource) == PP_FALSE);
- CHECK(ppb_url_request_info->IsURLRequestInfo(resource) == PP_TRUE);
- CHECK(ppb_url_response_info->IsURLResponseInfo(resource) == PP_FALSE);
- CHECK(ppb_url_loader->IsURLLoader(resource) == PP_FALSE);
- } else if (test_interface == PPB_URLRESPONSEINFO_INTERFACE) {
- CHECK(ppb_fileio->IsFileIO(resource) == PP_FALSE);
- CHECK(ppb_url_request_info->IsURLRequestInfo(resource) == PP_FALSE);
- CHECK(ppb_url_response_info->IsURLResponseInfo(resource) == PP_TRUE);
- CHECK(ppb_url_loader->IsURLLoader(resource) == PP_FALSE);
- } else if (test_interface == PPB_URLLOADER_INTERFACE) {
- CHECK(ppb_fileio->IsFileIO(resource) == PP_FALSE);
- CHECK(ppb_url_request_info->IsURLRequestInfo(resource) == PP_FALSE);
- CHECK(ppb_url_response_info->IsURLResponseInfo(resource) == PP_FALSE);
- CHECK(ppb_url_loader->IsURLLoader(resource) == PP_TRUE);
- }
-}
-
-void OpenCallback(void* user_data, int32_t pp_error) {
- UrlLoadRequest* obj = reinterpret_cast<UrlLoadRequest*>(user_data);
- if (NULL != obj)
- obj->OpenCallback(pp_error);
-}
-
-void FinishStreamingToFileCallback(void* user_data, int32_t pp_error) {
- UrlLoadRequest* obj = reinterpret_cast<UrlLoadRequest*>(user_data);
- if (NULL != obj)
- obj->FinishStreamingToFileCallback(pp_error);
-}
-
-void ReadResponseBodyCallback(void* user_data, int32_t pp_error_or_bytes) {
- UrlLoadRequest* obj = reinterpret_cast<UrlLoadRequest*>(user_data);
- if (NULL != obj)
- obj->ReadResponseBodyCallback(pp_error_or_bytes);
-}
-
-void OpenFileBodyCallback(void* user_data, int32_t pp_error) {
- UrlLoadRequest* obj = reinterpret_cast<UrlLoadRequest*>(user_data);
- if (NULL != obj)
- obj->OpenFileBodyCallback(pp_error);
-}
-
-void ReadFileBodyCallback(void* user_data, int32_t pp_error_or_bytes) {
- UrlLoadRequest* obj = reinterpret_cast<UrlLoadRequest*>(user_data);
- if (NULL != obj)
- obj->ReadFileBodyCallback(pp_error_or_bytes);
-}
-
-} // namespace
-
-
-UrlLoadRequest::UrlLoadRequest(PP_Instance instance)
- : delete_this_after_report(false),
- as_file_(false),
- instance_(instance),
- request_(0),
- loader_(0),
- response_(0),
- fileio_(0),
- request_interface_(NULL),
- loader_interface_(NULL),
- fileio_interface_(NULL),
- read_offset_(0) {
-}
-
-UrlLoadRequest::~UrlLoadRequest() {
- Clear();
-}
-
-void UrlLoadRequest::Clear() {
- Module* module = Module::Get();
- if (0 != request_) {
- module->ppb_core_interface()->ReleaseResource(request_);
- request_ = 0;
- }
- if (0 != loader_) {
- module->ppb_core_interface()->ReleaseResource(loader_);
- loader_ = 0;
- }
- if (0 != response_) {
- module->ppb_core_interface()->ReleaseResource(response_);
- response_ = 0;
- }
- if (0 != fileio_) {
- module->ppb_core_interface()->ReleaseResource(fileio_);
- fileio_ = 0;
- }
- url_body_.clear();
-}
-
-bool UrlLoadRequest::ReportSuccess() {
- Module::Get()->ReportResult(
- instance_, url_.c_str(), as_file_, url_body_.c_str(), true);
- if (delete_this_after_report) {
- delete this;
- }
- return true;
-}
-
-bool UrlLoadRequest::ReportFailure(const std::string& error) {
- Module::Get()->ReportResult(
- instance_, url_.c_str(), as_file_, error.c_str(), false);
- if (delete_this_after_report) {
- delete this;
- }
- return false;
-}
-
-bool UrlLoadRequest::ReportFailure(const std::string& message,
- int32_t pp_error) {
- std::string error = message;
- error.append(Module::ErrorCodeToStr(pp_error));
- return ReportFailure(error);
-}
-
-bool UrlLoadRequest::Load(bool as_file, std::string url) {
- printf("--- UrlLoadRequest::Load(as_file=%d, '%s')\n", as_file, url.c_str());
- url_ = url;
- as_file_ = as_file;
- Clear();
- std::string error;
- if (!GetRequiredInterfaces(&error)) {
- return ReportFailure(error);
- }
- PP_Bool set_url = request_interface_->SetProperty(
- request_, PP_URLREQUESTPROPERTY_URL, Module::StrToVar(url));
- PP_Bool set_method = request_interface_->SetProperty(
- request_, PP_URLREQUESTPROPERTY_METHOD, Module::StrToVar("GET"));
- PP_Bool pp_as_file = as_file ? PP_TRUE : PP_FALSE;
- PP_Bool set_file = request_interface_->SetProperty(
- request_, PP_URLREQUESTPROPERTY_STREAMTOFILE, PP_MakeBool(pp_as_file));
- if (set_url != PP_TRUE || set_method != PP_TRUE || set_file != PP_TRUE) {
- return ReportFailure("PPB_URLRequestInfo::SetProperty: failed");
- }
- loader_interface_->Open(
- loader_,
- request_,
- PP_MakeCompletionCallback(::OpenCallback, this));
- return true;
-}
-
-bool UrlLoadRequest::GetRequiredInterfaces(std::string* error) {
- Module* module = Module::Get();
-
- request_interface_ = static_cast<const PPB_URLRequestInfo*>(
- module->GetBrowserInterface(PPB_URLREQUESTINFO_INTERFACE));
- if (NULL == request_interface_) {
- *error = "Failed to get browser interface '" PPB_URLREQUESTINFO_INTERFACE;
- return false;
- }
- request_ = request_interface_->Create(instance_);
- if (0 == request_) {
- *error = "PPB_URLRequestInfo::Create: failed";
- return false;
- }
-
- response_interface_ = static_cast<const PPB_URLResponseInfo*>(
- module->GetBrowserInterface(PPB_URLRESPONSEINFO_INTERFACE));
- if (NULL == response_interface_) {
- *error = "Failed to get browser interface '" PPB_URLRESPONSEINFO_INTERFACE;
- return false;
- }
-
- loader_interface_ = static_cast<const PPB_URLLoader*>(
- module->GetBrowserInterface(PPB_URLLOADER_INTERFACE));
- if (NULL == loader_interface_) {
- *error = "Failed to get browser interface '" PPB_URLLOADER_INTERFACE;
- return false;
- }
- loader_ = loader_interface_->Create(instance_);
- if (0 == loader_) {
- *error = "PPB_URLLoader::Create: failed";
- return false;
- }
-
- fileio_interface_ = static_cast<const PPB_FileIO*>(
- module->GetBrowserInterface(PPB_FILEIO_INTERFACE));
- if (NULL == fileio_interface_) {
- *error = "Failed to get browser interface '" PPB_FILEIO_INTERFACE;
- return false;
- }
- fileio_ = fileio_interface_->Create(instance_);
- if (0 == fileio_) {
- *error = "PPB_FileIO::Create: failed";
- return false;
- }
-
- TestIsInterface(PPB_URLREQUESTINFO_INTERFACE, request_,
- fileio_interface_, request_interface_, response_interface_,
- loader_interface_);
- TestIsInterface(PPB_URLLOADER_INTERFACE, loader_,
- fileio_interface_, request_interface_, response_interface_,
- loader_interface_);
- TestIsInterface(PPB_FILEIO_INTERFACE, fileio_,
- fileio_interface_, request_interface_, response_interface_,
- loader_interface_);
-
- return true;
-}
-
-void UrlLoadRequest::ReadResponseBody() {
- loader_interface_->ReadResponseBody(
- loader_,
- buffer_,
- sizeof(buffer_),
- PP_MakeCompletionCallback(::ReadResponseBodyCallback, this));
-}
-
-void UrlLoadRequest::ReadFileBody() {
- fileio_interface_->Read(
- fileio_,
- read_offset_,
- buffer_,
- sizeof(buffer_),
- PP_MakeCompletionCallback(::ReadFileBodyCallback, this));
-}
-
-void UrlLoadRequest::OpenCallback(int32_t pp_error) {
- printf("--- UrlLoadRequest::OpenCallback\n");
- if (pp_error != PP_OK) {
- ReportFailure("UrlLoadRequest::OpenCallback: ", pp_error);
- return;
- }
-
- // Validating response headers to confirm successful loading.
- response_ = loader_interface_->GetResponseInfo(loader_);
- if (0 == response_) {
- ReportFailure("UrlLoadRequest::OpenCallback: null response");
- return;
- }
- TestIsInterface(PPB_URLRESPONSEINFO_INTERFACE, response_,
- fileio_interface_, request_interface_, response_interface_,
- loader_interface_);
- PP_Var url = response_interface_->GetProperty(response_,
- PP_URLRESPONSEPROPERTY_URL);
- if (url.type != PP_VARTYPE_STRING) {
- ReportFailure("URLLoadRequest::OpenCallback: bad url type");
- return;
- }
- url_ = Module::VarToStr(url); // Update url to be fully qualified.
- PP_Var status_code =
- response_interface_->GetProperty(response_,
- PP_URLRESPONSEPROPERTY_STATUSCODE);
- int32_t status_code_as_int = status_code.value.as_int;
- if (status_code_as_int != 200) { // Not HTTP OK.
- std::stringstream error;
- error << "OpenCallback: status_code=" << status_code_as_int;
- ReportFailure(error.str());
- return;
- }
-
- if (as_file_) {
- loader_interface_->FinishStreamingToFile(
- loader_,
- PP_MakeCompletionCallback(::FinishStreamingToFileCallback, this));
- } else {
- ReadResponseBody();
- }
-}
-
-void UrlLoadRequest::FinishStreamingToFileCallback(int32_t pp_error) {
- printf("--- UrlLoadRequest::FinishStreamingToFileCallback\n");
- if (pp_error != PP_OK) {
- ReportFailure("UrlLoadRequest::FinishStreamingToFileCallback: ", pp_error);
- return;
- }
- PP_Resource fileref = response_interface_->GetBodyAsFileRef(response_);
- if (0 == fileref) {
- ReportFailure("UrlLoadRequest::FinishStreamingToFileCallback: null file");
- return;
- }
- fileio_interface_->Open(
- fileio_,
- fileref,
- PP_FILEOPENFLAG_READ,
- PP_MakeCompletionCallback(::OpenFileBodyCallback, this));
-}
-
-void UrlLoadRequest::ReadResponseBodyCallback(int32_t pp_error_or_bytes) {
- printf("--- UrlLoadRequest::ReadResponseBodyCallback\n");
- if (pp_error_or_bytes < PP_OK) {
- ReportFailure("UrlLoadRequest::ReadResponseBodyCallback: ",
- pp_error_or_bytes);
- } else if (pp_error_or_bytes == PP_OK) { // Reached EOF.
- ReportSuccess();
- } else { // Partial read, so copy out the buffer and continue reading.
- for (int32_t i = 0; i < pp_error_or_bytes; i++)
- url_body_.push_back(buffer_[i]);
- ReadResponseBody();
- }
-}
-
-void UrlLoadRequest::ReadFileBodyCallback(int32_t pp_error_or_bytes) {
- printf("--- UrlLoadRequest::ReadFileBodyCallback\n");
- if (pp_error_or_bytes < PP_OK) {
- ReportFailure("UrlLoadRequest::ReadFileBodyCallback: ",
- pp_error_or_bytes);
- } else if (pp_error_or_bytes == PP_OK) { // Reached EOF.
- ReportSuccess();
- } else { // Partial read, so copy out the buffer and continue reading.
- for (int32_t i = 0; i < pp_error_or_bytes; i++)
- url_body_.push_back(buffer_[i]);
- read_offset_ += pp_error_or_bytes;
- ReadFileBody();
- }
-}
-
-void UrlLoadRequest::OpenFileBodyCallback(int32_t pp_error) {
- printf("--- UrlLoadRequest::OpenFileBodyCallback\n");
- if (pp_error != PP_OK) {
- ReportFailure("UrlLoadRequest::OpenFileBodyCallback: ", pp_error);
- return;
- }
- ReadFileBody();
-}
diff --git a/ppapi/native_client/tests/ppapi_geturl/url_load_request.h b/ppapi/native_client/tests/ppapi_geturl/url_load_request.h
deleted file mode 100644
index 079d3e3..0000000
--- a/ppapi/native_client/tests/ppapi_geturl/url_load_request.h
+++ /dev/null
@@ -1,79 +0,0 @@
-// 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 TESTS_PPAPI_GETURL_URL_LOAD_REQUEST_H_
-#define TESTS_PPAPI_GETURL_URL_LOAD_REQUEST_H_
-
-#include <string>
-#include <vector>
-
-#include "ppapi/c/ppb_file_io.h"
-#include "ppapi/c/ppb_file_ref.h"
-#include "ppapi/c/ppb_url_loader.h"
-#include "ppapi/c/ppb_url_request_info.h"
-#include "ppapi/c/ppb_url_response_info.h"
-#include "ppapi/c/pp_instance.h"
-#include "ppapi/c/pp_resource.h"
-#include "ppapi/c/pp_stdint.h"
-#if defined(__native_client__)
-// TODO(polina): add file_io_nacl include
-#else
-#include "ppapi/c/trusted/ppb_file_io_trusted.h"
-#endif
-
-
-class UrlLoadRequest {
- public:
- explicit UrlLoadRequest(PP_Instance instance);
- ~UrlLoadRequest();
- bool Load(bool stream_as_file, std::string url);
-
- void OpenCallback(int32_t pp_error);
- // Loading/reading via response includes the following asynchronous steps:
- // 1) URLLoader::Open
- // 2) URLLoader::ReadResponseBody (in a loop until EOF)
- void ReadResponseBodyCallback(int32_t pp_error_or_bytes);
- // Loading/reading via file includes the following asynchronous steps:
- // 1) URLLoader::Open
- // 2) URLLoader::FinishStreamingToFile
- // 3) FileIO::Open
- // 4) FileIO::Read (in a loop until EOF)
- void FinishStreamingToFileCallback(int32_t pp_error);
- void OpenFileBodyCallback(int32_t pp_error);
- void ReadFileBodyCallback(int32_t pp_error_or_bytes);
-
- void set_delete_this_after_report() { delete_this_after_report = true; }
-
- private:
- bool GetRequiredInterfaces(std::string* error);
- void Clear();
-
- void ReadResponseBody();
- void ReadFileBody();
-
- bool ReportSuccess();
- bool ReportFailure(const std::string& error);
- bool ReportFailure(const std::string& message, int32_t pp_error);
-
- bool delete_this_after_report;
-
- std::string url_;
- bool as_file_;
-
- PP_Instance instance_;
- PP_Resource request_;
- PP_Resource loader_;
- PP_Resource response_;
- PP_Resource fileio_;
-
- const PPB_URLRequestInfo* request_interface_;
- const PPB_URLResponseInfo* response_interface_;
- const PPB_URLLoader* loader_interface_;
- const PPB_FileIO* fileio_interface_;
-
- char buffer_[1024];
- std::string url_body_;
- int32_t read_offset_;
-};
-
-#endif // TESTS_PPAPI_GETURL_URL_LOAD_REQUEST_H_