| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef CONTENT_PUBLIC_TEST_TEST_UTILS_H_ | 5 #ifndef CONTENT_PUBLIC_TEST_TEST_UTILS_H_ |
| 6 #define CONTENT_PUBLIC_TEST_TEST_UTILS_H_ | 6 #define CONTENT_PUBLIC_TEST_TEST_UTILS_H_ |
| 7 | 7 |
| 8 #include <memory> |
| 9 |
| 8 #include "base/callback.h" | 10 #include "base/callback.h" |
| 9 #include "base/macros.h" | 11 #include "base/macros.h" |
| 10 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 11 #include "base/memory/scoped_ptr.h" | |
| 12 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
| 13 #include "build/build_config.h" | 14 #include "build/build_config.h" |
| 14 #include "content/public/browser/browser_child_process_observer.h" | 15 #include "content/public/browser/browser_child_process_observer.h" |
| 15 #include "content/public/browser/browser_thread.h" | 16 #include "content/public/browser/browser_thread.h" |
| 16 #include "content/public/browser/notification_details.h" | 17 #include "content/public/browser/notification_details.h" |
| 17 #include "content/public/browser/notification_observer.h" | 18 #include "content/public/browser/notification_observer.h" |
| 18 #include "content/public/browser/notification_registrar.h" | 19 #include "content/public/browser/notification_registrar.h" |
| 19 #include "content/public/browser/notification_source.h" | 20 #include "content/public/browser/notification_source.h" |
| 20 #include "content/public/browser/web_contents_observer.h" | 21 #include "content/public/browser/web_contents_observer.h" |
| 21 | 22 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 void RunAllBlockingPoolTasksUntilIdle(); | 58 void RunAllBlockingPoolTasksUntilIdle(); |
| 58 | 59 |
| 59 // Get task to quit the given RunLoop. It allows a few generations of pending | 60 // Get task to quit the given RunLoop. It allows a few generations of pending |
| 60 // tasks to run as opposed to run_loop->QuitClosure(). | 61 // tasks to run as opposed to run_loop->QuitClosure(). |
| 61 base::Closure GetQuitTaskForRunLoop(base::RunLoop* run_loop); | 62 base::Closure GetQuitTaskForRunLoop(base::RunLoop* run_loop); |
| 62 | 63 |
| 63 // Executes the specified JavaScript in the specified frame, and runs a nested | 64 // Executes the specified JavaScript in the specified frame, and runs a nested |
| 64 // MessageLoop. When the result is available, it is returned. | 65 // MessageLoop. When the result is available, it is returned. |
| 65 // This should not be used; the use of the ExecuteScript functions in | 66 // This should not be used; the use of the ExecuteScript functions in |
| 66 // browser_test_utils is preferable. | 67 // browser_test_utils is preferable. |
| 67 scoped_ptr<base::Value> ExecuteScriptAndGetValue( | 68 std::unique_ptr<base::Value> ExecuteScriptAndGetValue( |
| 68 RenderFrameHost* render_frame_host, const std::string& script); | 69 RenderFrameHost* render_frame_host, |
| 70 const std::string& script); |
| 69 | 71 |
| 70 // Returns true if all sites are isolated. Typically used to bail from a test | 72 // Returns true if all sites are isolated. Typically used to bail from a test |
| 71 // that is incompatible with --site-per-process. | 73 // that is incompatible with --site-per-process. |
| 72 bool AreAllSitesIsolatedForTesting(); | 74 bool AreAllSitesIsolatedForTesting(); |
| 73 | 75 |
| 74 // Appends --site-per-process to the command line, enabling tests to exercise | 76 // Appends --site-per-process to the command line, enabling tests to exercise |
| 75 // site isolation and cross-process iframes. This must be called early in | 77 // site isolation and cross-process iframes. This must be called early in |
| 76 // the test; the flag will be read on the first real navigation. | 78 // the test; the flag will be read on the first real navigation. |
| 77 void IsolateAllSitesForTesting(base::CommandLine* command_line); | 79 void IsolateAllSitesForTesting(base::CommandLine* command_line); |
| 78 | 80 |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 // Overridden WebContentsObserver methods. | 251 // Overridden WebContentsObserver methods. |
| 250 void RenderFrameDeleted(RenderFrameHost* render_frame_host) override; | 252 void RenderFrameDeleted(RenderFrameHost* render_frame_host) override; |
| 251 | 253 |
| 252 void WaitUntilDeleted(); | 254 void WaitUntilDeleted(); |
| 253 bool deleted(); | 255 bool deleted(); |
| 254 | 256 |
| 255 private: | 257 private: |
| 256 int process_id_; | 258 int process_id_; |
| 257 int routing_id_; | 259 int routing_id_; |
| 258 bool deleted_; | 260 bool deleted_; |
| 259 scoped_ptr<base::RunLoop> runner_; | 261 std::unique_ptr<base::RunLoop> runner_; |
| 260 | 262 |
| 261 DISALLOW_COPY_AND_ASSIGN(RenderFrameDeletedObserver); | 263 DISALLOW_COPY_AND_ASSIGN(RenderFrameDeletedObserver); |
| 262 }; | 264 }; |
| 263 | 265 |
| 264 // Watches a WebContents and blocks until it is destroyed. | 266 // Watches a WebContents and blocks until it is destroyed. |
| 265 class WebContentsDestroyedWatcher : public WebContentsObserver { | 267 class WebContentsDestroyedWatcher : public WebContentsObserver { |
| 266 public: | 268 public: |
| 267 explicit WebContentsDestroyedWatcher(WebContents* web_contents); | 269 explicit WebContentsDestroyedWatcher(WebContents* web_contents); |
| 268 ~WebContentsDestroyedWatcher() override; | 270 ~WebContentsDestroyedWatcher() override; |
| 269 | 271 |
| 270 // Waits until the WebContents is destroyed. | 272 // Waits until the WebContents is destroyed. |
| 271 void Wait(); | 273 void Wait(); |
| 272 | 274 |
| 273 private: | 275 private: |
| 274 // Overridden WebContentsObserver methods. | 276 // Overridden WebContentsObserver methods. |
| 275 void WebContentsDestroyed() override; | 277 void WebContentsDestroyed() override; |
| 276 | 278 |
| 277 scoped_refptr<MessageLoopRunner> message_loop_runner_; | 279 scoped_refptr<MessageLoopRunner> message_loop_runner_; |
| 278 | 280 |
| 279 DISALLOW_COPY_AND_ASSIGN(WebContentsDestroyedWatcher); | 281 DISALLOW_COPY_AND_ASSIGN(WebContentsDestroyedWatcher); |
| 280 }; | 282 }; |
| 281 | 283 |
| 282 } // namespace content | 284 } // namespace content |
| 283 | 285 |
| 284 #endif // CONTENT_PUBLIC_TEST_TEST_UTILS_H_ | 286 #endif // CONTENT_PUBLIC_TEST_TEST_UTILS_H_ |
| OLD | NEW |