Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Unified Diff: ppapi/tests/test_url_loader.cc

Issue 9139076: Added bounds checks to the URLLoader prefetch buffer threshhold. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ppapi/tests/test_url_loader.h ('k') | webkit/plugins/ppapi/ppb_url_request_info_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/tests/test_url_loader.cc
diff --git a/ppapi/tests/test_url_loader.cc b/ppapi/tests/test_url_loader.cc
index 741d4155eb46a8bb15e3edc7f039c788a5bb720e..f27b3a5b3d39124350ff60231e68bc1b294898ed 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,9 @@ 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(NegativePrefetchBufferThreshold, filter);
+ RUN_TEST_FORCEASYNC_AND_NOT(LegalPrefetchBufferThreshold, filter);
+ RUN_TEST_FORCEASYNC_AND_NOT(InvertedPrefetchBufferThreshold, filter);
}
std::string TestURLLoader::ReadEntireFile(pp::FileIO* file_io,
@@ -871,6 +874,47 @@ 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);
+
+ int32_t rv = OpenUntrusted(request);
+ return rv;
+}
+
+std::string TestURLLoader::TestNegativePrefetchBufferThreshold() {
+ 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);
+ }
+
+ PASS();
+}
+
+std::string TestURLLoader::TestLegalPrefetchBufferThreshold() {
+ int32_t rv = OpenWithPrefetchBufferThreshold(0, 1);
+ if (rv != PP_OK) {
+ return ReportError("The prefetch buffer limits were legal values but "
+ "the URLLoader failed.", rv);
+ }
+
+ PASS();
+}
+
+std::string TestURLLoader::TestInvertedPrefetchBufferThreshold() {
+ int32_t 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);
+ }
+
dmichael (off chromium) 2012/01/13 17:46:02 I think it would make sense to collapse these in t
+ PASS();
+}
+
// TODO(viettrungluu): Add tests for Get{Upload,Download}Progress, Close
// (including abort tests if applicable).
« no previous file with comments | « ppapi/tests/test_url_loader.h ('k') | webkit/plugins/ppapi/ppb_url_request_info_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698