Skip to content

Commit

Permalink
[unseasoned-pdf] Add unit tests for DocumentLoadComplete().
Browse files Browse the repository at this point in the history
Add unit tests for PdfViewPluginBase::DocumentLoadComplete(), which
exercises multiple private methods: DidStopLoading(), SendAttachments(),
SendBookmarks(), SendMetadata(), SendLoadingProgress() and
LoadAccessibility().

Also make `AccessibilityState` and `kMaximumSavedFileSize` public so
that they can be used in unit tests.

Change-Id: I8d548dd1f2eb5f9e6d860b0d8f1e1fe4fb329389
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2986560
Commit-Queue: Hui Yingst <nigi@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#898413}
  • Loading branch information
Hui Yingst authored and Chromium LUCI CQ committed Jul 3, 2021
1 parent 12259ab commit 13d2d16
Show file tree
Hide file tree
Showing 4 changed files with 393 additions and 10 deletions.
10 changes: 10 additions & 0 deletions pdf/accessibility_structs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@

namespace chrome_pdf {

bool AccessibilityDocInfo::operator==(const AccessibilityDocInfo& other) const {
return page_count == other.page_count &&
text_accessible == other.text_accessible &&
text_copyable == other.text_copyable;
}

bool AccessibilityDocInfo::operator!=(const AccessibilityDocInfo& other) const {
return !(*this == other);
}

AccessibilityTextStyleInfo::AccessibilityTextStyleInfo() = default;

AccessibilityTextStyleInfo::AccessibilityTextStyleInfo(
Expand Down
3 changes: 3 additions & 0 deletions pdf/accessibility_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
namespace chrome_pdf {

struct AccessibilityDocInfo {
bool operator==(const AccessibilityDocInfo& other) const;
bool operator!=(const AccessibilityDocInfo& other) const;

uint32_t page_count = 0;
bool text_accessible = false;
bool text_copyable = false;
Expand Down
20 changes: 10 additions & 10 deletions pdf/pdf_view_plugin_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,16 @@ class PdfViewPluginBase : public PDFEngine::Client,
public:
using PDFEngine::Client::ScheduleTaskOnMainThread;

// Do not save files with over 100 MB. This cap should be kept in sync with
// and is also enforced in chrome/browser/resources/pdf/pdf_viewer.js.
static constexpr size_t kMaximumSavedFileSize = 100 * 1000 * 1000;

enum class AccessibilityState {
kOff = 0, // Off.
kPending, // Enabled but waiting for doc to load.
kLoaded, // Fully loaded.
};

enum class DocumentLoadState {
kLoading = 0,
kComplete,
Expand Down Expand Up @@ -148,16 +158,6 @@ class PdfViewPluginBase : public PDFEngine::Client,
}

protected:
// Do not save files with over 100 MB. This cap should be kept in sync with
// and is also enforced in chrome/browser/resources/pdf/pdf_viewer.js.
static constexpr size_t kMaximumSavedFileSize = 100 * 1000 * 1000;

enum class AccessibilityState {
kOff = 0, // Off.
kPending, // Enabled but waiting for doc to load.
kLoaded, // Fully loaded.
};

struct BackgroundPart {
gfx::Rect location;
uint32_t color;
Expand Down
Loading

0 comments on commit 13d2d16

Please sign in to comment.