OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "base/callback.h" | 5 #include "base/callback.h" |
| 6 #include "base/location.h" |
6 #include "base/logging.h" | 7 #include "base/logging.h" |
7 #include "base/message_loop/message_loop.h" | |
8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "base/single_thread_task_runner.h" |
10 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 #include "base/thread_task_runner_handle.h" |
11 #include "base/time/time.h" | 13 #include "base/time/time.h" |
12 #include "base/values.h" | 14 #include "base/values.h" |
13 #include "components/dom_distiller/content/web_contents_main_frame_observer.h" | 15 #include "components/dom_distiller/content/web_contents_main_frame_observer.h" |
14 #include "content/public/browser/navigation_controller.h" | 16 #include "content/public/browser/navigation_controller.h" |
15 #include "content/public/browser/render_frame_host.h" | 17 #include "content/public/browser/render_frame_host.h" |
16 #include "content/public/browser/web_contents_observer.h" | 18 #include "content/public/browser/web_contents_observer.h" |
17 #include "content/public/test/content_browser_test.h" | 19 #include "content/public/test/content_browser_test.h" |
18 #include "content/shell/browser/shell.h" | 20 #include "content/shell/browser/shell.h" |
19 #include "net/test/embedded_test_server/embedded_test_server.h" | 21 #include "net/test/embedded_test_server/embedded_test_server.h" |
20 #include "ui/base/resource/resource_bundle.h" | 22 #include "ui/base/resource/resource_bundle.h" |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 content::Referrer(), | 112 content::Referrer(), |
111 ui::PAGE_TRANSITION_TYPED, | 113 ui::PAGE_TRANSITION_TYPED, |
112 std::string()); | 114 std::string()); |
113 url_loaded_runner.Run(); | 115 url_loaded_runner.Run(); |
114 | 116 |
115 // Execute the JS to run the tests, and wait until it has finished. | 117 // Execute the JS to run the tests, and wait until it has finished. |
116 base::RunLoop run_loop; | 118 base::RunLoop run_loop; |
117 js_test_execution_done_callback_ = run_loop.QuitClosure(); | 119 js_test_execution_done_callback_ = run_loop.QuitClosure(); |
118 // Add timeout in case JS Test execution fails. It is safe to call the | 120 // Add timeout in case JS Test execution fails. It is safe to call the |
119 // QuitClosure multiple times. | 121 // QuitClosure multiple times. |
120 base::MessageLoop::current()->PostDelayedTask( | 122 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
121 FROM_HERE, run_loop.QuitClosure(), base::TimeDelta::FromSeconds(15)); | 123 FROM_HERE, run_loop.QuitClosure(), base::TimeDelta::FromSeconds(15)); |
122 web_contents->GetMainFrame()->ExecuteJavaScript( | 124 web_contents->GetMainFrame()->ExecuteJavaScript( |
123 base::UTF8ToUTF16(kRunJsTestsJs), | 125 base::UTF8ToUTF16(kRunJsTestsJs), |
124 base::Bind(&DomDistillerJsTest::OnJsTestExecutionDone, | 126 base::Bind(&DomDistillerJsTest::OnJsTestExecutionDone, |
125 base::Unretained(this))); | 127 base::Unretained(this))); |
126 run_loop.Run(); | 128 run_loop.Run(); |
127 | 129 |
128 // By now either the timeout has triggered, or there should be a result. | 130 // By now either the timeout has triggered, or there should be a result. |
129 ASSERT_TRUE(result_ != NULL) << "No result found. Timeout?"; | 131 ASSERT_TRUE(result_ != NULL) << "No result found. Timeout?"; |
130 | 132 |
(...skipping 26 matching lines...) Expand all Loading... |
157 // Only print the log if there was an error. | 159 // Only print the log if there was an error. |
158 if (!success) { | 160 if (!success) { |
159 ASSERT_TRUE(dict->HasKey("log")); | 161 ASSERT_TRUE(dict->HasKey("log")); |
160 std::string console_log; | 162 std::string console_log; |
161 ASSERT_TRUE(dict->GetString("log", &console_log)); | 163 ASSERT_TRUE(dict->GetString("log", &console_log)); |
162 VLOG(0) << "Console log:\n" << console_log; | 164 VLOG(0) << "Console log:\n" << console_log; |
163 } | 165 } |
164 } | 166 } |
165 | 167 |
166 } // namespace dom_distiller | 168 } // namespace dom_distiller |
OLD | NEW |