| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 BLIMP_ENGINE_BROWSER_TESTS_BLIMP_BROWSER_TEST_H_ | 5 #ifndef BLIMP_ENGINE_BROWSER_TESTS_BLIMP_BROWSER_TEST_H_ |
| 6 #define BLIMP_ENGINE_BROWSER_TESTS_BLIMP_BROWSER_TEST_H_ | 6 #define BLIMP_ENGINE_BROWSER_TESTS_BLIMP_BROWSER_TEST_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/synchronization/waitable_event.h" | 10 #include "base/synchronization/waitable_event.h" |
| 11 #include "base/threading/thread_restrictions.h" |
| 11 #include "content/public/test/browser_test_base.h" | 12 #include "content/public/test/browser_test_base.h" |
| 12 | 13 |
| 13 namespace base { | 14 namespace base { |
| 14 class RunLoop; | 15 class RunLoop; |
| 15 } | 16 } |
| 16 | 17 |
| 17 namespace content { | 18 namespace content { |
| 18 class WebContents; | 19 class WebContents; |
| 19 } | 20 } |
| 20 | 21 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 39 void SignalCompletion(); | 40 void SignalCompletion(); |
| 40 | 41 |
| 41 protected: | 42 protected: |
| 42 BlimpBrowserTest(); | 43 BlimpBrowserTest(); |
| 43 ~BlimpBrowserTest() override; | 44 ~BlimpBrowserTest() override; |
| 44 | 45 |
| 45 // Processes tasks in the UI and IO thread until SignalCompletion() is | 46 // Processes tasks in the UI and IO thread until SignalCompletion() is |
| 46 // called. | 47 // called. |
| 47 void RunUntilCompletion(); | 48 void RunUntilCompletion(); |
| 48 | 49 |
| 50 // Allow the UI thread to wait. This bypasses base::ThreadRestrictions and is |
| 51 // used for client/engine integration tests. |
| 52 void AllowUIWaits(); |
| 53 |
| 49 engine::BlimpEngineSession* GetEngineSession(); | 54 engine::BlimpEngineSession* GetEngineSession(); |
| 50 | 55 |
| 51 client::Assignment GetAssignment(); | 56 client::Assignment GetAssignment(); |
| 52 | 57 |
| 53 // testing::Test implementation. | 58 // testing::Test implementation. |
| 54 void SetUp() override; | 59 void SetUp() override; |
| 55 | 60 |
| 56 // content::BrowserTestBase implementation. | 61 // content::BrowserTestBase implementation. |
| 57 void RunTestOnMainThreadLoop() override; | 62 void RunTestOnMainThreadLoop() override; |
| 58 void SetUpCommandLine(base::CommandLine* command_line) override; | 63 void SetUpCommandLine(base::CommandLine* command_line) override; |
| 59 void SetUpOnMainThread() override; | 64 void SetUpOnMainThread() override; |
| 60 void TearDownOnMainThread() override; | 65 void TearDownOnMainThread() override; |
| 61 | 66 |
| 62 private: | 67 private: |
| 63 // Receives the port number from an asynchronously connected socket. | 68 // Receives the port number from an asynchronously connected socket. |
| 64 // Calls SignalCompletion() when set. | 69 // Calls SignalCompletion() when set. |
| 65 void OnGetEnginePortCompletion(uint16_t port); | 70 void OnGetEnginePortCompletion(uint16_t port); |
| 66 | 71 |
| 67 uint16_t engine_port_; | 72 uint16_t engine_port_; |
| 68 | 73 |
| 69 // Used to signal the completion of asynchronous processing to | 74 // Used to signal the completion of asynchronous processing to |
| 70 // RunUntilCompletion(). | 75 // RunUntilCompletion(). |
| 71 base::WaitableEvent completion_event_; | 76 base::WaitableEvent completion_event_; |
| 72 | 77 |
| 78 // Used to allow UI thread waits. This is useful for integration tests that |
| 79 // require setting up client components, as testing those sometimes requires |
| 80 // setting up GL contexts that might block. |
| 81 std::unique_ptr<base::ThreadRestrictions::ScopedAllowWait> allow_ui_waits_; |
| 82 |
| 73 DISALLOW_COPY_AND_ASSIGN(BlimpBrowserTest); | 83 DISALLOW_COPY_AND_ASSIGN(BlimpBrowserTest); |
| 74 }; | 84 }; |
| 75 | 85 |
| 76 } // namespace blimp | 86 } // namespace blimp |
| 77 | 87 |
| 78 #endif // BLIMP_ENGINE_BROWSER_TESTS_BLIMP_BROWSER_TEST_H_ | 88 #endif // BLIMP_ENGINE_BROWSER_TESTS_BLIMP_BROWSER_TEST_H_ |
| OLD | NEW |