| 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" |
| 11 #include "chrome/browser/ui/browser.h" | 11 #include "chrome/browser/ui/browser.h" |
| 12 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 12 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 13 #include "chrome/common/chrome_switches.h" | 13 #include "chrome/common/chrome_switches.h" |
| 14 #include "chrome/test/base/in_process_browser_test.h" | 14 #include "chrome/test/base/in_process_browser_test.h" |
| 15 #include "chrome/test/base/ui_test_utils.h" | 15 #include "chrome/test/base/ui_test_utils.h" |
| 16 #include "components/dom_distiller/content/web_contents_main_frame_observer.h" | 16 #include "components/dom_distiller/content/web_contents_main_frame_observer.h" |
| 17 #include "components/dom_distiller/core/dom_distiller_service.h" | 17 #include "components/dom_distiller/core/dom_distiller_service.h" |
| 18 #include "components/dom_distiller/core/task_tracker.h" | 18 #include "components/dom_distiller/core/task_tracker.h" |
| 19 #include "components/dom_distiller/core/url_constants.h" | 19 #include "components/dom_distiller/core/url_constants.h" |
| 20 #include "components/dom_distiller/core/url_utils.h" | 20 #include "components/dom_distiller/core/url_utils.h" |
| 21 #include "content/public/browser/render_frame_host.h" | 21 #include "content/public/browser/render_frame_host.h" |
| 22 #include "content/public/browser/web_contents.h" | 22 #include "content/public/browser/web_contents.h" |
| 23 #include "content/public/browser/web_contents_observer.h" | 23 #include "content/public/browser/web_contents_observer.h" |
| 24 #include "content/public/test/test_utils.h" |
| 24 #include "net/test/embedded_test_server/embedded_test_server.h" | 25 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 25 #include "testing/gtest/include/gtest/gtest.h" | 26 #include "testing/gtest/include/gtest/gtest.h" |
| 26 | 27 |
| 27 namespace dom_distiller { | 28 namespace dom_distiller { |
| 28 | 29 |
| 29 namespace { | 30 namespace { |
| 30 const char* kSimpleArticlePath = "/dom_distiller/simple_article.html"; | 31 const char* kSimpleArticlePath = "/dom_distiller/simple_article.html"; |
| 31 } // namespace | 32 } // namespace |
| 32 | 33 |
| 33 class DomDistillerTabUtilsBrowserTest : public InProcessBrowserTest { | 34 class DomDistillerTabUtilsBrowserTest : public InProcessBrowserTest { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 // Wait until the new WebContents has fully navigated. | 79 // Wait until the new WebContents has fully navigated. |
| 79 content::WebContents* after_web_contents = | 80 content::WebContents* after_web_contents = |
| 80 browser()->tab_strip_model()->GetActiveWebContents(); | 81 browser()->tab_strip_model()->GetActiveWebContents(); |
| 81 ASSERT_TRUE(after_web_contents != NULL); | 82 ASSERT_TRUE(after_web_contents != NULL); |
| 82 base::RunLoop new_url_loaded_runner; | 83 base::RunLoop new_url_loaded_runner; |
| 83 scoped_ptr<WebContentsMainFrameHelper> distilled_page_loaded( | 84 scoped_ptr<WebContentsMainFrameHelper> distilled_page_loaded( |
| 84 new WebContentsMainFrameHelper(after_web_contents, | 85 new WebContentsMainFrameHelper(after_web_contents, |
| 85 new_url_loaded_runner.QuitClosure())); | 86 new_url_loaded_runner.QuitClosure())); |
| 86 new_url_loaded_runner.Run(); | 87 new_url_loaded_runner.Run(); |
| 87 | 88 |
| 89 std::string page_title; |
| 90 content::ExecuteScriptAndGetValue(after_web_contents->GetMainFrame(), |
| 91 "document.title")->GetAsString(&page_title); |
| 92 |
| 88 // Verify the new URL is showing distilled content in a new WebContents. | 93 // Verify the new URL is showing distilled content in a new WebContents. |
| 89 EXPECT_NE(initial_web_contents, after_web_contents); | 94 EXPECT_NE(initial_web_contents, after_web_contents); |
| 90 EXPECT_TRUE( | 95 EXPECT_TRUE( |
| 91 after_web_contents->GetLastCommittedURL().SchemeIs(kDomDistillerScheme)); | 96 after_web_contents->GetLastCommittedURL().SchemeIs(kDomDistillerScheme)); |
| 92 EXPECT_EQ("Test Page Title", | 97 EXPECT_EQ("Test Page Title", page_title); |
| 93 base::UTF16ToUTF8(after_web_contents->GetTitle())); | |
| 94 } | 98 } |
| 95 | 99 |
| 96 } // namespace dom_distiller | 100 } // namespace dom_distiller |
| OLD | NEW |