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

Unified Diff: components/dom_distiller/core/test_request_view_handle.h

Issue 1130703003: Show template before distiller finishes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ios-superclass
Patch Set: Fix flaky test Created 5 years, 7 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
Index: components/dom_distiller/core/test_request_view_handle.h
diff --git a/components/dom_distiller/core/test_request_view_handle.h b/components/dom_distiller/core/test_request_view_handle.h
new file mode 100644
index 0000000000000000000000000000000000000000..5271e59cb919dd402d679c84fc99b35fe588417b
--- /dev/null
+++ b/components/dom_distiller/core/test_request_view_handle.h
@@ -0,0 +1,52 @@
+// 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.
+
+#ifndef COMPONENTS_DOM_DISTILLER_CORE_TEST_REQUEST_VIEW_HANDLE_H_
+#define COMPONENTS_DOM_DISTILLER_CORE_TEST_REQUEST_VIEW_HANDLE_H_
+
+#include <string>
+
+#include "components/dom_distiller/core/distilled_page_prefs.h"
+#include "components/dom_distiller/core/dom_distiller_request_view_base.h"
+
+namespace dom_distiller {
+
+// TestRequestViewHandle allows the javascript buffer to be collected at any
+// point and viewed. This class is for testing only.
+class TestRequestViewHandle : public DomDistillerRequestViewBase {
+ public:
+ TestRequestViewHandle(DistilledPagePrefs* prefs);
+ ~TestRequestViewHandle() override;
+
+ std::string GetJavaScriptBuffer();
+ void ClearJavaScriptBuffer();
+
+ private:
+ void SendJavaScript(const std::string& buffer) override;
+ std::string buffer_;
+};
+
+TestRequestViewHandle::TestRequestViewHandle(DistilledPagePrefs* prefs)
+ : DomDistillerRequestViewBase(prefs) {
+}
+
+TestRequestViewHandle::~TestRequestViewHandle() {
+ distilled_page_prefs_->RemoveObserver(this);
+}
+
+std::string TestRequestViewHandle::GetJavaScriptBuffer() {
+ return buffer_;
+}
+
+void TestRequestViewHandle::ClearJavaScriptBuffer() {
+ buffer_ = "";
+}
+
+void TestRequestViewHandle::SendJavaScript(const std::string& buffer) {
+ buffer_ += buffer;
+}
+
+} // namespace dom_distiller
+
+#endif // COMPONENTS_DOM_DISTILLER_CORE_TEST_REQUEST_VIEW_HANDLE_H_
« no previous file with comments | « components/dom_distiller/core/javascript/dom_distiller_viewer.js ('k') | components/dom_distiller/core/viewer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698