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

Unified Diff: chrome/test/data/pdf/test_util.js

Issue 838723003: Testcases for nameddests and navigate for PDF (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changes as per review comments. Created 5 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 | « chrome/test/data/pdf/params_parser_test.js ('k') | chrome/test/data/pdf/viewport_test.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/data/pdf/test_util.js
diff --git a/chrome/test/data/pdf/test_util.js b/chrome/test/data/pdf/test_util.js
new file mode 100644
index 0000000000000000000000000000000000000000..8ea2a81cd9fd3ec609836f67690a9ee49ec1dea3
--- /dev/null
+++ b/chrome/test/data/pdf/test_util.js
@@ -0,0 +1,89 @@
+// Copyright 2015 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.
+
+// Utilities that are used in multiple tests.
+function MockWindow(width, height, sizer) {
+ this.innerWidth = width;
+ this.innerHeight = height;
+ this.addEventListener = function(e, f) {
+ if (e == 'scroll')
+ this.scrollCallback = f;
+ if (e == 'resize')
+ this.resizeCallback = f;
+ };
+ this.scrollTo = function(x, y) {
+ if (sizer) {
+ x = Math.min(x, parseInt(sizer.style.width) - width);
+ y = Math.min(y, parseInt(sizer.style.height) - height);
+ }
+ this.pageXOffset = Math.max(0, x);
+ this.pageYOffset = Math.max(0, y);
+ this.scrollCallback();
+ };
+ if (sizer) {
+ sizer.resizeCallback_ = function() {
+ this.scrollTo(this.pageXOffset, this.pageYOffset);
+ }.bind(this);
+ }
+ this.pageXOffset = 0;
+ this.pageYOffset = 0;
+ this.scrollCallback = null;
+ this.resizeCallback = null;
+}
+
+function MockSizer() {
+ var sizer = this;
+ this.style = {
+ width_: '0px',
+ height_: '0px',
+ get height() { return this.height_; },
+ set height(height) {
+ this.height_ = height;
+ if (sizer.resizeCallback_)
+ sizer.resizeCallback_();
+ },
+ get width() { return this.width_; },
+ set width(width) {
+ this.width_ = width;
+ if (sizer.resizeCallback_)
+ sizer.resizeCallback_();
+ },
+ };
+}
+
+function MockViewportChangedCallback() {
+ this.wasCalled = false;
+ this.callback = function() {
+ this.wasCalled = true;
+ }.bind(this);
+ this.reset = function() {
+ this.wasCalled = false;
+ };
+}
+
+function MockDocumentDimensions(width, height) {
+ this.width = width || 0;
+ this.height = height ? height : 0;
+ this.pageDimensions = [];
+ this.addPage = function(w, h) {
+ var y = 0;
+ if (this.pageDimensions.length != 0) {
+ y = this.pageDimensions[this.pageDimensions.length - 1].y +
+ this.pageDimensions[this.pageDimensions.length - 1].height;
+ }
+ this.width = Math.max(this.width, w);
+ this.height += h;
+ this.pageDimensions.push({
+ x: 0,
+ y: y,
+ width: w,
+ height: h
+ });
+ };
+ this.reset = function() {
+ this.width = 0;
+ this.height = 0;
+ this.pageDimensions = [];
+ };
+}
« no previous file with comments | « chrome/test/data/pdf/params_parser_test.js ('k') | chrome/test/data/pdf/viewport_test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698