| Index: components/dom_distiller/content/distiller_page_web_contents_browsertest.cc
|
| diff --git a/components/dom_distiller/content/distiller_page_web_contents_browsertest.cc b/components/dom_distiller/content/distiller_page_web_contents_browsertest.cc
|
| index dadefe77dc17f73cb700930bb85f945a23db2f50..25789edb1c85fa429ebb338ad02d70f144560952 100644
|
| --- a/components/dom_distiller/content/distiller_page_web_contents_browsertest.cc
|
| +++ b/components/dom_distiller/content/distiller_page_web_contents_browsertest.cc
|
| @@ -5,6 +5,7 @@
|
| #include "base/memory/weak_ptr.h"
|
| #include "base/path_service.h"
|
| #include "base/run_loop.h"
|
| +#include "base/strings/utf_string_conversions.h"
|
| #include "base/values.h"
|
| #include "components/dom_distiller/content/distiller_page_web_contents.h"
|
| #include "components/dom_distiller/content/web_contents_main_frame_observer.h"
|
| @@ -60,6 +61,11 @@ class DistillerPageWebContentsTest : public ContentBrowserTest {
|
| quit_closure_.Run();
|
| }
|
|
|
| + void OnJsExecutionDone(base::Closure callback, const base::Value* value) {
|
| + js_result_ = value->DeepCopy();
|
| + callback.Run();
|
| + }
|
| +
|
| private:
|
| void AddComponentsResources() {
|
| base::FilePath pak_file;
|
| @@ -88,6 +94,7 @@ class DistillerPageWebContentsTest : public ContentBrowserTest {
|
| DistillerPageWebContents* distiller_page_;
|
| base::Closure quit_closure_;
|
| scoped_ptr<proto::DomDistillerResult> distiller_result_;
|
| + const base::Value* js_result_;
|
| };
|
|
|
| // Use this class to be able to leak the WebContents, which is needed for when
|
| @@ -519,4 +526,40 @@ IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest,
|
| }
|
| }
|
|
|
| +IN_PROC_BROWSER_TEST_F(DistillerPageWebContentsTest,
|
| + TestPinch) {
|
| + // Load the test file in content shell and wait until it has fully loaded.
|
| + content::WebContents* web_contents = shell()->web_contents();
|
| + dom_distiller::WebContentsMainFrameObserver::CreateForWebContents(
|
| + web_contents);
|
| + base::RunLoop url_loaded_runner;
|
| + WebContentsMainFrameHelper main_frame_loaded(web_contents,
|
| + url_loaded_runner.QuitClosure(),
|
| + true);
|
| + web_contents->GetController().LoadURL(
|
| + embedded_test_server()->GetURL("pinch_tester.html"),
|
| + content::Referrer(),
|
| + ui::PAGE_TRANSITION_TYPED,
|
| + std::string());
|
| + url_loaded_runner.Run();
|
| +
|
| + // Execute the JS to run the tests, and wait until it has finished.
|
| + base::RunLoop run_loop;
|
| + web_contents->GetMainFrame()->ExecuteJavaScript(
|
| + base::UTF8ToUTF16("(function() {return pinchtest.run();})();"),
|
| + base::Bind(&DistillerPageWebContentsTest::OnJsExecutionDone,
|
| + base::Unretained(this), run_loop.QuitClosure()));
|
| + run_loop.Run();
|
| +
|
| + // Convert to dictionary and parse the results.
|
| + const base::DictionaryValue* dict;
|
| + js_result_->GetAsDictionary(&dict);
|
| + ASSERT_TRUE(js_result_->GetAsDictionary(&dict));
|
| +
|
| + ASSERT_TRUE(dict->HasKey("success"));
|
| + bool success;
|
| + ASSERT_TRUE(dict->GetBoolean("success", &success));
|
| + EXPECT_TRUE(success);
|
| +}
|
| +
|
| } // namespace dom_distiller
|
|
|