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

Side by Side Diff: content/shell/test_runner/test_runner.cc

Issue 2928033002: Move GetDocument method from WebFrame to WebLocalFrame. (Closed)
Patch Set: Split a DCHECK in two as suggested by boliu@. Created 3 years, 6 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
OLDNEW
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 "content/shell/test_runner/test_runner.h" 5 #include "content/shell/test_runner/test_runner.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8
9 #include <algorithm>
8 #include <limits> 10 #include <limits>
9 #include <utility> 11 #include <utility>
10 12
11 #include "base/command_line.h" 13 #include "base/command_line.h"
12 #include "base/logging.h" 14 #include "base/logging.h"
13 #include "base/macros.h" 15 #include "base/macros.h"
14 #include "base/strings/nullable_string16.h" 16 #include "base/strings/nullable_string16.h"
15 #include "base/strings/string_number_conversions.h" 17 #include "base/strings/string_number_conversions.h"
16 #include "base/strings/stringprintf.h" 18 #include "base/strings/stringprintf.h"
17 #include "base/strings/utf_string_conversions.h" 19 #include "base/strings/utf_string_conversions.h"
(...skipping 1974 matching lines...) Expand 10 before | Expand all | Expand 10 after
1992 : blink::WebSettings::kV8CacheOptionsDefault); 1994 : blink::WebSettings::kV8CacheOptionsDefault);
1993 } 1995 }
1994 1996
1995 void TestRunner::ShowDevTools(const std::string& settings, 1997 void TestRunner::ShowDevTools(const std::string& settings,
1996 const std::string& frontend_url) { 1998 const std::string& frontend_url) {
1997 delegate_->ShowDevTools(settings, frontend_url); 1999 delegate_->ShowDevTools(settings, frontend_url);
1998 } 2000 }
1999 2001
2000 class WorkItemBackForward : public TestRunner::WorkItem { 2002 class WorkItemBackForward : public TestRunner::WorkItem {
2001 public: 2003 public:
2002 WorkItemBackForward(int distance) : distance_(distance) {} 2004 explicit WorkItemBackForward(int distance) : distance_(distance) {}
2003 2005
2004 bool Run(WebTestDelegate* delegate, WebView*) override { 2006 bool Run(WebTestDelegate* delegate, WebView*) override {
2005 delegate->GoToOffset(distance_); 2007 delegate->GoToOffset(distance_);
2006 return true; // FIXME: Did it really start a navigation? 2008 return true; // FIXME: Did it really start a navigation?
2007 } 2009 }
2008 2010
2009 private: 2011 private:
2010 int distance_; 2012 int distance_;
2011 }; 2013 };
2012 2014
(...skipping 17 matching lines...) Expand all
2030 return true; 2032 return true;
2031 } 2033 }
2032 }; 2034 };
2033 2035
2034 void TestRunner::QueueReload() { 2036 void TestRunner::QueueReload() {
2035 work_queue_.AddWork(new WorkItemReload()); 2037 work_queue_.AddWork(new WorkItemReload());
2036 } 2038 }
2037 2039
2038 class WorkItemLoadingScript : public TestRunner::WorkItem { 2040 class WorkItemLoadingScript : public TestRunner::WorkItem {
2039 public: 2041 public:
2040 WorkItemLoadingScript(const std::string& script) : script_(script) {} 2042 explicit WorkItemLoadingScript(const std::string& script) : script_(script) {}
2041 2043
2042 bool Run(WebTestDelegate*, WebView* web_view) override { 2044 bool Run(WebTestDelegate*, WebView* web_view) override {
2043 blink::WebFrame* main_frame = web_view->MainFrame(); 2045 blink::WebFrame* main_frame = web_view->MainFrame();
2044 if (!main_frame->IsWebLocalFrame()) { 2046 if (!main_frame->IsWebLocalFrame()) {
2045 CHECK(false) << "This function cannot be called if the main frame is not " 2047 CHECK(false) << "This function cannot be called if the main frame is not "
2046 "a local frame."; 2048 "a local frame.";
2047 return false; 2049 return false;
2048 } 2050 }
2049 main_frame->ToWebLocalFrame()->ExecuteScript( 2051 main_frame->ToWebLocalFrame()->ExecuteScript(
2050 WebScriptSource(WebString::FromUTF8(script_))); 2052 WebScriptSource(WebString::FromUTF8(script_)));
2051 return true; // FIXME: Did it really start a navigation? 2053 return true; // FIXME: Did it really start a navigation?
2052 } 2054 }
2053 2055
2054 private: 2056 private:
2055 std::string script_; 2057 std::string script_;
2056 }; 2058 };
2057 2059
2058 void TestRunner::QueueLoadingScript(const std::string& script) { 2060 void TestRunner::QueueLoadingScript(const std::string& script) {
2059 work_queue_.AddWork(new WorkItemLoadingScript(script)); 2061 work_queue_.AddWork(new WorkItemLoadingScript(script));
2060 } 2062 }
2061 2063
2062 class WorkItemNonLoadingScript : public TestRunner::WorkItem { 2064 class WorkItemNonLoadingScript : public TestRunner::WorkItem {
2063 public: 2065 public:
2064 WorkItemNonLoadingScript(const std::string& script) : script_(script) {} 2066 explicit WorkItemNonLoadingScript(const std::string& script)
2067 : script_(script) {}
2065 2068
2066 bool Run(WebTestDelegate*, WebView* web_view) override { 2069 bool Run(WebTestDelegate*, WebView* web_view) override {
2067 blink::WebFrame* main_frame = web_view->MainFrame(); 2070 blink::WebFrame* main_frame = web_view->MainFrame();
2068 if (!main_frame->IsWebLocalFrame()) { 2071 if (!main_frame->IsWebLocalFrame()) {
2069 CHECK(false) << "This function cannot be called if the main frame is not " 2072 CHECK(false) << "This function cannot be called if the main frame is not "
2070 "a local frame."; 2073 "a local frame.";
2071 return false; 2074 return false;
2072 } 2075 }
2073 main_frame->ToWebLocalFrame()->ExecuteScript( 2076 main_frame->ToWebLocalFrame()->ExecuteScript(
2074 WebScriptSource(WebString::FromUTF8(script_))); 2077 WebScriptSource(WebString::FromUTF8(script_)));
(...skipping 20 matching lines...) Expand all
2095 2098
2096 private: 2099 private:
2097 WebURL url_; 2100 WebURL url_;
2098 std::string target_; 2101 std::string target_;
2099 }; 2102 };
2100 2103
2101 void TestRunner::QueueLoad(const std::string& url, const std::string& target) { 2104 void TestRunner::QueueLoad(const std::string& url, const std::string& target) {
2102 if (!main_view_) 2105 if (!main_view_)
2103 return; 2106 return;
2104 2107
2108 // TODO(lukasza): testRunner.queueLoad(...) should work even if the main frame
2109 // is remote (ideally testRunner.queueLoad would bind to and execute in the
2110 // context of a specific local frame - resolving relative urls should be done
2111 // on relative to the calling frame's url).
2112 CHECK(main_view_->MainFrame()->IsWebLocalFrame())
2113 << "This function cannot be called if the main frame is not "
2114 "a local frame.";
2115
2105 // FIXME: Implement WebURL::resolve() and avoid GURL. 2116 // FIXME: Implement WebURL::resolve() and avoid GURL.
2106 GURL current_url = main_view_->MainFrame()->GetDocument().Url(); 2117 GURL current_url =
2118 main_view_->MainFrame()->ToWebLocalFrame()->GetDocument().Url();
2107 GURL full_url = current_url.Resolve(url); 2119 GURL full_url = current_url.Resolve(url);
2108 work_queue_.AddWork(new WorkItemLoad(full_url, target)); 2120 work_queue_.AddWork(new WorkItemLoad(full_url, target));
2109 } 2121 }
2110 2122
2111 void TestRunner::SetCustomPolicyDelegate(gin::Arguments* args) { 2123 void TestRunner::SetCustomPolicyDelegate(gin::Arguments* args) {
2112 bool value; 2124 bool value;
2113 args->GetNext(&value); 2125 args->GetNext(&value);
2114 layout_test_runtime_flags_.set_policy_delegate_enabled(value); 2126 layout_test_runtime_flags_.set_policy_delegate_enabled(value);
2115 2127
2116 if (!args->PeekNext().IsEmpty() && args->PeekNext()->IsBoolean()) { 2128 if (!args->PeekNext().IsEmpty() && args->PeekNext()->IsBoolean()) {
(...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after
2814 2826
2815 void TestRunner::NotifyDone() { 2827 void TestRunner::NotifyDone() {
2816 if (layout_test_runtime_flags_.wait_until_done() && !topLoadingFrame() && 2828 if (layout_test_runtime_flags_.wait_until_done() && !topLoadingFrame() &&
2817 !will_navigate_ && work_queue_.is_empty()) 2829 !will_navigate_ && work_queue_.is_empty())
2818 delegate_->TestFinished(); 2830 delegate_->TestFinished();
2819 layout_test_runtime_flags_.set_wait_until_done(false); 2831 layout_test_runtime_flags_.set_wait_until_done(false);
2820 OnLayoutTestRuntimeFlagsChanged(); 2832 OnLayoutTestRuntimeFlagsChanged();
2821 } 2833 }
2822 2834
2823 } // namespace test_runner 2835 } // namespace test_runner
OLDNEW
« no previous file with comments | « content/shell/test_runner/pixel_dump.cc ('k') | content/shell/test_runner/test_runner_for_specific_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698