test_client.cc 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. // Copyright 2018 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "pdf/test/test_client.h"
  5. #include <memory>
  6. #include "base/time/time.h"
  7. #include "pdf/document_layout.h"
  8. #include "pdf/loader/url_loader.h"
  9. #include "third_party/skia/include/core/SkColor.h"
  10. namespace chrome_pdf {
  11. TestClient::TestClient() = default;
  12. TestClient::~TestClient() = default;
  13. void TestClient::ProposeDocumentLayout(const DocumentLayout& layout) {
  14. // Most tests will want to accept the proposed layout immediately: Applying
  15. // layout asynchronously is more accurate, but in most cases, doing so adds
  16. // complexity without much gain. Instead, we can override this behavior just
  17. // where it matters (like PDFiumEngineTest.ProposeDocumentLayoutWithOverlap).
  18. engine()->ApplyDocumentLayout(layout.options());
  19. }
  20. bool TestClient::Confirm(const std::string& message) {
  21. return false;
  22. }
  23. std::string TestClient::Prompt(const std::string& question,
  24. const std::string& default_answer) {
  25. return std::string();
  26. }
  27. std::string TestClient::GetURL() {
  28. return std::string();
  29. }
  30. std::unique_ptr<UrlLoader> TestClient::CreateUrlLoader() {
  31. return nullptr;
  32. }
  33. std::vector<PDFEngine::Client::SearchStringResult> TestClient::SearchString(
  34. const char16_t* string,
  35. const char16_t* term,
  36. bool case_sensitive) {
  37. return std::vector<SearchStringResult>();
  38. }
  39. bool TestClient::IsPrintPreview() const {
  40. return false;
  41. }
  42. SkColor TestClient::GetBackgroundColor() const {
  43. return SK_ColorTRANSPARENT;
  44. }
  45. void TestClient::SetSelectedText(const std::string& selected_text) {}
  46. void TestClient::SetLinkUnderCursor(const std::string& link_under_cursor) {}
  47. bool TestClient::IsValidLink(const std::string& url) {
  48. return !url.empty();
  49. }
  50. } // namespace chrome_pdf