| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <string.h> | 5 #include <string.h> |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/browser/dom_distiller/dom_distiller_service_factory.h" | 9 #include "chrome/browser/dom_distiller/dom_distiller_service_factory.h" |
| 10 #include "chrome/browser/dom_distiller/tab_utils.h" | 10 #include "chrome/browser/dom_distiller/tab_utils.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 #include "testing/gtest/include/gtest/gtest.h" | 25 #include "testing/gtest/include/gtest/gtest.h" |
| 26 | 26 |
| 27 namespace dom_distiller { | 27 namespace dom_distiller { |
| 28 | 28 |
| 29 namespace { | 29 namespace { |
| 30 const char* kSimpleArticlePath = "/dom_distiller/simple_article.html"; | 30 const char* kSimpleArticlePath = "/dom_distiller/simple_article.html"; |
| 31 } // namespace | 31 } // namespace |
| 32 | 32 |
| 33 class DomDistillerTabUtilsBrowserTest : public InProcessBrowserTest { | 33 class DomDistillerTabUtilsBrowserTest : public InProcessBrowserTest { |
| 34 public: | 34 public: |
| 35 virtual void SetUpCommandLine(CommandLine* command_line) override { | 35 void SetUpCommandLine(CommandLine* command_line) override { |
| 36 command_line->AppendSwitch(switches::kEnableDomDistiller); | 36 command_line->AppendSwitch(switches::kEnableDomDistiller); |
| 37 } | 37 } |
| 38 }; | 38 }; |
| 39 | 39 |
| 40 class WebContentsMainFrameHelper : public content::WebContentsObserver { | 40 class WebContentsMainFrameHelper : public content::WebContentsObserver { |
| 41 public: | 41 public: |
| 42 WebContentsMainFrameHelper(content::WebContents* web_contents, | 42 WebContentsMainFrameHelper(content::WebContents* web_contents, |
| 43 const base::Closure& callback) | 43 const base::Closure& callback) |
| 44 : callback_(callback) { | 44 : callback_(callback) { |
| 45 content::WebContentsObserver::Observe(web_contents); | 45 content::WebContentsObserver::Observe(web_contents); |
| 46 } | 46 } |
| 47 | 47 |
| 48 virtual void DidFinishLoad(content::RenderFrameHost* render_frame_host, | 48 void DidFinishLoad(content::RenderFrameHost* render_frame_host, |
| 49 const GURL& validated_url) override { | 49 const GURL& validated_url) override { |
| 50 if (!render_frame_host->GetParent() && | 50 if (!render_frame_host->GetParent() && |
| 51 validated_url.scheme() == kDomDistillerScheme) | 51 validated_url.scheme() == kDomDistillerScheme) |
| 52 callback_.Run(); | 52 callback_.Run(); |
| 53 } | 53 } |
| 54 | 54 |
| 55 private: | 55 private: |
| 56 base::Closure callback_; | 56 base::Closure callback_; |
| 57 }; | 57 }; |
| 58 | 58 |
| 59 IN_PROC_BROWSER_TEST_F(DomDistillerTabUtilsBrowserTest, TestSwapWebContents) { | 59 IN_PROC_BROWSER_TEST_F(DomDistillerTabUtilsBrowserTest, TestSwapWebContents) { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 80 | 80 |
| 81 // Verify the new URL is showing distilled content in a new WebContents. | 81 // Verify the new URL is showing distilled content in a new WebContents. |
| 82 EXPECT_NE(initial_web_contents, after_web_contents); | 82 EXPECT_NE(initial_web_contents, after_web_contents); |
| 83 EXPECT_TRUE( | 83 EXPECT_TRUE( |
| 84 after_web_contents->GetLastCommittedURL().SchemeIs(kDomDistillerScheme)); | 84 after_web_contents->GetLastCommittedURL().SchemeIs(kDomDistillerScheme)); |
| 85 EXPECT_EQ("Test Page Title", | 85 EXPECT_EQ("Test Page Title", |
| 86 base::UTF16ToUTF8(after_web_contents->GetTitle())); | 86 base::UTF16ToUTF8(after_web_contents->GetTitle())); |
| 87 } | 87 } |
| 88 | 88 |
| 89 } // namespace dom_distiller | 89 } // namespace dom_distiller |
| OLD | NEW |