| 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 "content/public/browser/browser_thread.h" | 12 #include "content/public/browser/browser_thread.h" |
| 13 #include "content/public/browser/notification_details.h" | 13 #include "content/public/browser/notification_details.h" |
| 14 #include "content/public/browser/notification_observer.h" | 14 #include "content/public/browser/notification_observer.h" |
| 15 #include "content/public/browser/notification_registrar.h" | 15 #include "content/public/browser/notification_registrar.h" |
| 16 #include "content/public/browser/notification_source.h" | 16 #include "content/public/browser/notification_source.h" |
| 17 | 17 |
| 18 namespace base { | 18 namespace base { |
| 19 class Value; | 19 class Value; |
| 20 } | 20 } |
| 21 | 21 |
| 22 namespace net { |
| 23 class CookieStore; |
| 24 } |
| 25 |
| 22 // A collection of functions designed for use with unit and browser tests. | 26 // A collection of functions designed for use with unit and browser tests. |
| 23 | 27 |
| 24 namespace content { | 28 namespace content { |
| 25 | 29 |
| 26 class RenderViewHost; | 30 class RenderViewHost; |
| 31 class StoragePartition; |
| 27 | 32 |
| 28 // Turns on nestable tasks, runs the message loop, then resets nestable tasks | 33 // Turns on nestable tasks, runs the message loop, then resets nestable tasks |
| 29 // to what they were originally. Prefer this over MessageLoop::Run for in | 34 // to what they were originally. Prefer this over MessageLoop::Run for in |
| 30 // process browser tests that need to block until a condition is met. | 35 // process browser tests that need to block until a condition is met. |
| 31 void RunMessageLoop(); | 36 void RunMessageLoop(); |
| 32 | 37 |
| 33 // Variant of RunMessageLoop that takes RunLoop. | 38 // Variant of RunMessageLoop that takes RunLoop. |
| 34 void RunThisRunLoop(base::RunLoop* run_loop); | 39 void RunThisRunLoop(base::RunLoop* run_loop); |
| 35 | 40 |
| 36 // Turns on nestable tasks, runs all pending tasks in the message loop, | 41 // Turns on nestable tasks, runs all pending tasks in the message loop, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 48 base::Closure GetQuitTaskForRunLoop(base::RunLoop* run_loop); | 53 base::Closure GetQuitTaskForRunLoop(base::RunLoop* run_loop); |
| 49 | 54 |
| 50 // Executes the specified javascript in the top-level frame, and runs a nested | 55 // Executes the specified javascript in the top-level frame, and runs a nested |
| 51 // MessageLoop. When the result is available, it is returned. | 56 // MessageLoop. When the result is available, it is returned. |
| 52 // This should not be used; the use of the ExecuteScript functions in | 57 // This should not be used; the use of the ExecuteScript functions in |
| 53 // browser_test_utils is preferable. | 58 // browser_test_utils is preferable. |
| 54 scoped_ptr<base::Value> ExecuteScriptAndGetValue( | 59 scoped_ptr<base::Value> ExecuteScriptAndGetValue( |
| 55 RenderViewHost* render_view_host, | 60 RenderViewHost* render_view_host, |
| 56 const std::string& script); | 61 const std::string& script); |
| 57 | 62 |
| 63 net::CookieStore* GetCookieStoreForScheme( |
| 64 StoragePartition* storage_partition, |
| 65 const std::string& scheme); |
| 66 |
| 58 // Helper class to Run and Quit the message loop. Run and Quit can only happen | 67 // Helper class to Run and Quit the message loop. Run and Quit can only happen |
| 59 // once per instance. Make a new instance for each use. Calling Quit after Run | 68 // once per instance. Make a new instance for each use. Calling Quit after Run |
| 60 // has returned is safe and has no effect. | 69 // has returned is safe and has no effect. |
| 61 class MessageLoopRunner : public base::RefCounted<MessageLoopRunner> { | 70 class MessageLoopRunner : public base::RefCounted<MessageLoopRunner> { |
| 62 public: | 71 public: |
| 63 MessageLoopRunner(); | 72 MessageLoopRunner(); |
| 64 | 73 |
| 65 // Run the current MessageLoop unless the quit closure | 74 // Run the current MessageLoop unless the quit closure |
| 66 // has already been called. | 75 // has already been called. |
| 67 void Run(); | 76 void Run(); |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 NotificationSource source_; | 173 NotificationSource source_; |
| 165 NotificationDetails details_; | 174 NotificationDetails details_; |
| 166 scoped_refptr<MessageLoopRunner> message_loop_runner_; | 175 scoped_refptr<MessageLoopRunner> message_loop_runner_; |
| 167 | 176 |
| 168 DISALLOW_COPY_AND_ASSIGN(WindowedNotificationObserver); | 177 DISALLOW_COPY_AND_ASSIGN(WindowedNotificationObserver); |
| 169 }; | 178 }; |
| 170 | 179 |
| 171 } // namespace content | 180 } // namespace content |
| 172 | 181 |
| 173 #endif // CONTENT_PUBLIC_TEST_TEST_UTILS_H_ | 182 #endif // CONTENT_PUBLIC_TEST_TEST_UTILS_H_ |
| OLD | NEW |