summaryrefslogtreecommitdiffstats
path: root/ppapi/tests
diff options
context:
space:
mode:
authorraymes@chromium.org <raymes@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-17 22:10:14 +0000
committerraymes@chromium.org <raymes@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-17 22:10:14 +0000
commit94af0572c1f5a4c60ebb40a2ce76bbe754b2551d (patch)
treead35601739c3932c561eec005ad79979dd8ea677 /ppapi/tests
parent37a70e2decc3a457d3b0d95944638c7418f5e474 (diff)
downloadchromium_src-94af0572c1f5a4c60ebb40a2ce76bbe754b2551d.zip
chromium_src-94af0572c1f5a4c60ebb40a2ce76bbe754b2551d.tar.gz
chromium_src-94af0572c1f5a4c60ebb40a2ce76bbe754b2551d.tar.bz2
Added bounds checks to the URLLoader prefetch buffer threshhold.
BUG=89842 TEST=./ui_tests --gtest_filter=PPAPITest.URLLoader*PrefetchBufferThreshold Review URL: http://codereview.chromium.org/9139076 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@117970 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/tests')
-rw-r--r--ppapi/tests/test_url_loader.cc36
-rw-r--r--ppapi/tests/test_url_loader.h2
2 files changed, 36 insertions, 2 deletions
diff --git a/ppapi/tests/test_url_loader.cc b/ppapi/tests/test_url_loader.cc
index 741d415..2b0a66b 100644
--- a/ppapi/tests/test_url_loader.cc
+++ b/ppapi/tests/test_url_loader.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// 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.
@@ -117,6 +117,7 @@ void TestURLLoader::RunTests(const std::string& filter) {
RUN_TEST_FORCEASYNC_AND_NOT(AuditURLRedirect, filter);
RUN_TEST_FORCEASYNC_AND_NOT(AbortCalls, filter);
RUN_TEST_FORCEASYNC_AND_NOT(UntendedLoad, filter);
+ RUN_TEST_FORCEASYNC_AND_NOT(PrefetchBufferThreshold, filter);
}
std::string TestURLLoader::ReadEntireFile(pp::FileIO* file_io,
@@ -871,6 +872,37 @@ std::string TestURLLoader::TestUntendedLoad() {
PASS();
}
+int32_t TestURLLoader::OpenWithPrefetchBufferThreshold(int32_t lower,
+ int32_t upper) {
+ pp::URLRequestInfo request(instance_);
+ request.SetURL("test_url_loader_data/hello.txt");
+ request.SetPrefetchBufferLowerThreshold(lower);
+ request.SetPrefetchBufferUpperThreshold(upper);
+
+ return OpenUntrusted(request);
+}
+
+std::string TestURLLoader::TestPrefetchBufferThreshold() {
+ int32_t rv = OpenWithPrefetchBufferThreshold(-1, 1);
+ if (rv != PP_ERROR_FAILED) {
+ return ReportError("The prefetch limits contained a negative value but "
+ "the URLLoader did not fail.", rv);
+ }
+
+ rv = OpenWithPrefetchBufferThreshold(0, 1);
+ if (rv != PP_OK) {
+ return ReportError("The prefetch buffer limits were legal values but "
+ "the URLLoader failed.", rv);
+ }
+
+ rv = OpenWithPrefetchBufferThreshold(1000, 1);
+ if (rv != PP_ERROR_FAILED) {
+ return ReportError("The lower buffer value was higher than the upper but "
+ "the URLLoader did not fail.", rv);
+ }
+
+ PASS();
+}
+
// TODO(viettrungluu): Add tests for Get{Upload,Download}Progress, Close
// (including abort tests if applicable).
-
diff --git a/ppapi/tests/test_url_loader.h b/ppapi/tests/test_url_loader.h
index 8dbef70e..95c97b1 100644
--- a/ppapi/tests/test_url_loader.h
+++ b/ppapi/tests/test_url_loader.h
@@ -47,6 +47,7 @@ class TestURLLoader : public TestCase {
const std::string& header);
int32_t Open(const pp::URLRequestInfo& request,
bool with_universal_access);
+ int32_t OpenWithPrefetchBufferThreshold(int32_t lower, int32_t upper);
std::string TestBasicGET();
std::string TestBasicPOST();
@@ -70,6 +71,7 @@ class TestURLLoader : public TestCase {
std::string TestAuditURLRedirect();
std::string TestAbortCalls();
std::string TestUntendedLoad();
+ std::string TestPrefetchBufferThreshold();
const PPB_FileIOTrusted* file_io_trusted_interface_;
const PPB_URLLoaderTrusted* url_loader_trusted_interface_;