| 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 "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
| 12 #include "build/build_config.h" |
| 12 #include "content/public/browser/browser_child_process_observer.h" | 13 #include "content/public/browser/browser_child_process_observer.h" |
| 13 #include "content/public/browser/browser_thread.h" | 14 #include "content/public/browser/browser_thread.h" |
| 14 #include "content/public/browser/notification_details.h" | 15 #include "content/public/browser/notification_details.h" |
| 15 #include "content/public/browser/notification_observer.h" | 16 #include "content/public/browser/notification_observer.h" |
| 16 #include "content/public/browser/notification_registrar.h" | 17 #include "content/public/browser/notification_registrar.h" |
| 17 #include "content/public/browser/notification_source.h" | 18 #include "content/public/browser/notification_source.h" |
| 18 #include "content/public/browser/web_contents_observer.h" | 19 #include "content/public/browser/web_contents_observer.h" |
| 19 | 20 |
| 21 #if defined(OS_ANDROID) |
| 22 #include <jni.h> |
| 23 #endif |
| 24 |
| 20 namespace base { | 25 namespace base { |
| 21 class Value; | 26 class Value; |
| 22 class CommandLine; | 27 class CommandLine; |
| 23 } // namespace base | 28 } // namespace base |
| 24 | 29 |
| 25 // A collection of functions designed for use with unit and browser tests. | 30 // A collection of functions designed for use with unit and browser tests. |
| 26 | 31 |
| 27 namespace content { | 32 namespace content { |
| 28 | 33 |
| 29 class RenderFrameHost; | 34 class RenderFrameHost; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 | 68 |
| 64 // Returns true if all sites are isolated. Typically used to bail from a test | 69 // Returns true if all sites are isolated. Typically used to bail from a test |
| 65 // that is incompatible with --site-per-process. | 70 // that is incompatible with --site-per-process. |
| 66 bool AreAllSitesIsolatedForTesting(); | 71 bool AreAllSitesIsolatedForTesting(); |
| 67 | 72 |
| 68 // Appends --site-per-process to the command line, enabling tests to exercise | 73 // Appends --site-per-process to the command line, enabling tests to exercise |
| 69 // site isolation and cross-process iframes. This must be called early in | 74 // site isolation and cross-process iframes. This must be called early in |
| 70 // the test; the flag will be read on the first real navigation. | 75 // the test; the flag will be read on the first real navigation. |
| 71 void IsolateAllSitesForTesting(base::CommandLine* command_line); | 76 void IsolateAllSitesForTesting(base::CommandLine* command_line); |
| 72 | 77 |
| 78 #if defined(OS_ANDROID) |
| 79 // Registers content/browser JNI bindings necessary for some types of tests. |
| 80 bool RegisterJniForTesting(JNIEnv* env); |
| 81 #endif |
| 82 |
| 73 // Helper class to Run and Quit the message loop. Run and Quit can only happen | 83 // Helper class to Run and Quit the message loop. Run and Quit can only happen |
| 74 // once per instance. Make a new instance for each use. Calling Quit after Run | 84 // once per instance. Make a new instance for each use. Calling Quit after Run |
| 75 // has returned is safe and has no effect. | 85 // has returned is safe and has no effect. |
| 76 class MessageLoopRunner : public base::RefCounted<MessageLoopRunner> { | 86 class MessageLoopRunner : public base::RefCounted<MessageLoopRunner> { |
| 77 public: | 87 public: |
| 78 MessageLoopRunner(); | 88 MessageLoopRunner(); |
| 79 | 89 |
| 80 // Run the current MessageLoop unless the quit closure | 90 // Run the current MessageLoop unless the quit closure |
| 81 // has already been called. | 91 // has already been called. |
| 82 void Run(); | 92 void Run(); |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 void WebContentsDestroyed() override; | 274 void WebContentsDestroyed() override; |
| 265 | 275 |
| 266 scoped_refptr<MessageLoopRunner> message_loop_runner_; | 276 scoped_refptr<MessageLoopRunner> message_loop_runner_; |
| 267 | 277 |
| 268 DISALLOW_COPY_AND_ASSIGN(WebContentsDestroyedWatcher); | 278 DISALLOW_COPY_AND_ASSIGN(WebContentsDestroyedWatcher); |
| 269 }; | 279 }; |
| 270 | 280 |
| 271 } // namespace content | 281 } // namespace content |
| 272 | 282 |
| 273 #endif // CONTENT_PUBLIC_TEST_TEST_UTILS_H_ | 283 #endif // CONTENT_PUBLIC_TEST_TEST_UTILS_H_ |
| OLD | NEW |