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

Side by Side Diff: components/dom_distiller/content/browser/distiller_page_web_contents_browsertest.cc

Issue 2650653008: Convert Distiller browser test to use the new navigation callbacks. (Closed)
Patch Set: Created 3 years, 10 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "components/dom_distiller/content/browser/distiller_page_web_contents.h " 5 #include "components/dom_distiller/content/browser/distiller_page_web_contents.h "
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
11 #include "base/path_service.h" 11 #include "base/path_service.h"
12 #include "base/run_loop.h" 12 #include "base/run_loop.h"
13 #include "base/single_thread_task_runner.h" 13 #include "base/single_thread_task_runner.h"
14 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
15 #include "base/threading/thread_task_runner_handle.h" 15 #include "base/threading/thread_task_runner_handle.h"
16 #include "base/values.h" 16 #include "base/values.h"
17 #include "build/build_config.h" 17 #include "build/build_config.h"
18 #include "components/dom_distiller/content/browser/distiller_javascript_utils.h" 18 #include "components/dom_distiller/content/browser/distiller_javascript_utils.h"
19 #include "components/dom_distiller/content/browser/web_contents_main_frame_obser ver.h" 19 #include "components/dom_distiller/content/browser/web_contents_main_frame_obser ver.h"
20 #include "components/dom_distiller/core/distiller_page.h" 20 #include "components/dom_distiller/core/distiller_page.h"
21 #include "components/dom_distiller/core/proto/distilled_article.pb.h" 21 #include "components/dom_distiller/core/proto/distilled_article.pb.h"
22 #include "components/dom_distiller/core/proto/distilled_page.pb.h" 22 #include "components/dom_distiller/core/proto/distilled_page.pb.h"
23 #include "components/dom_distiller/core/viewer.h" 23 #include "components/dom_distiller/core/viewer.h"
24 #include "content/public/browser/browser_context.h" 24 #include "content/public/browser/browser_context.h"
25 #include "content/public/browser/navigation_controller.h" 25 #include "content/public/browser/navigation_controller.h"
26 #include "content/public/browser/navigation_handle.h"
26 #include "content/public/browser/render_frame_host.h" 27 #include "content/public/browser/render_frame_host.h"
27 #include "content/public/browser/web_contents_observer.h" 28 #include "content/public/browser/web_contents_observer.h"
28 #include "content/public/common/isolated_world_ids.h" 29 #include "content/public/common/isolated_world_ids.h"
29 #include "content/public/test/content_browser_test.h" 30 #include "content/public/test/content_browser_test.h"
30 #include "content/shell/browser/shell.h" 31 #include "content/shell/browser/shell.h"
31 #include "grit/components_strings.h" 32 #include "grit/components_strings.h"
32 #include "net/test/embedded_test_server/embedded_test_server.h" 33 #include "net/test/embedded_test_server/embedded_test_server.h"
33 #include "testing/gmock/include/gmock/gmock.h" 34 #include "testing/gmock/include/gmock/gmock.h"
34 #include "third_party/dom_distiller_js/dom_distiller.pb.h" 35 #include "third_party/dom_distiller_js/dom_distiller.pb.h"
35 #include "ui/base/l10n/l10n_util.h" 36 #include "ui/base/l10n/l10n_util.h"
(...skipping 12 matching lines...) Expand all
48 // main frame, based on the value of |wait_for_document_loaded|. 49 // main frame, based on the value of |wait_for_document_loaded|.
49 class WebContentsMainFrameHelper : public content::WebContentsObserver { 50 class WebContentsMainFrameHelper : public content::WebContentsObserver {
50 public: 51 public:
51 WebContentsMainFrameHelper(content::WebContents* web_contents, 52 WebContentsMainFrameHelper(content::WebContents* web_contents,
52 const base::Closure& callback, 53 const base::Closure& callback,
53 bool wait_for_document_loaded) 54 bool wait_for_document_loaded)
54 : WebContentsObserver(web_contents), 55 : WebContentsObserver(web_contents),
55 callback_(callback), 56 callback_(callback),
56 wait_for_document_loaded_(wait_for_document_loaded) {} 57 wait_for_document_loaded_(wait_for_document_loaded) {}
57 58
58 void DidCommitProvisionalLoadForFrame( 59 void DidFinishNavigation(
59 content::RenderFrameHost* render_frame_host, 60 content::NavigationHandle* navigation_handle) override {
60 const GURL& url,
61 ui::PageTransition transition_type) override {
62 if (wait_for_document_loaded_) 61 if (wait_for_document_loaded_)
63 return; 62 return;
64 if (!render_frame_host->GetParent()) 63 if (navigation_handle->HasCommitted() && navigation_handle->IsInMainFrame())
65 callback_.Run(); 64 callback_.Run();
66 } 65 }
67 66
68 void DocumentLoadedInFrame( 67 void DocumentLoadedInFrame(
69 content::RenderFrameHost* render_frame_host) override { 68 content::RenderFrameHost* render_frame_host) override {
70 if (wait_for_document_loaded_) { 69 if (wait_for_document_loaded_) {
71 if (!render_frame_host->GetParent()) 70 if (!render_frame_host->GetParent())
72 callback_.Run(); 71 callback_.Run();
73 } 72 }
74 } 73 }
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 ASSERT_TRUE(js_result_); 519 ASSERT_TRUE(js_result_);
521 ASSERT_TRUE(js_result_->GetAsDictionary(&dict)); 520 ASSERT_TRUE(js_result_->GetAsDictionary(&dict));
522 521
523 ASSERT_TRUE(dict->HasKey("success")); 522 ASSERT_TRUE(dict->HasKey("success"));
524 bool success; 523 bool success;
525 ASSERT_TRUE(dict->GetBoolean("success", &success)); 524 ASSERT_TRUE(dict->GetBoolean("success", &success));
526 EXPECT_TRUE(success); 525 EXPECT_TRUE(success);
527 } 526 }
528 527
529 } // namespace dom_distiller 528 } // namespace dom_distiller
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698