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 3 // found in the LICENSE file. 4 5 #ifndef THIRD_PARTY_BLINK_RENDERER_CORE_TESTING_SIM_SIM_TEST_H_ 6 #define THIRD_PARTY_BLINK_RENDERER_CORE_TESTING_SIM_SIM_TEST_H_ 7 8 #include <gtest/gtest.h> 9 #include "third_party/blink/public/platform/web_effective_connection_type.h" 10 #include "third_party/blink/renderer/core/frame/frame_test_helpers.h" 11 #include "third_party/blink/renderer/core/testing/sim/sim_compositor.h" 12 #include "third_party/blink/renderer/core/testing/sim/sim_network.h" 13 #include "third_party/blink/renderer/core/testing/sim/sim_page.h" 14 15 namespace blink { 16 17 class WebViewImpl; 18 class WebLocalFrameImpl; 19 class Document; 20 class LocalDOMWindow; 21 22 class SimTest : public testing::Test { 23 protected: 24 SimTest(); 25 ~SimTest() override; 26 27 void SetUp() override; 28 void TearDown() override; 29 30 // Create a remote frame as the main frame and create a local child frame. 31 void InitializeRemote(); 32 33 // Load URL in the local frame root. 34 void LoadURL(const String& url); 35 36 // WebView is created after SetUp to allow test to customize 37 // web runtime features. 38 // These methods should be accessed inside test body after a call to SetUp. 39 LocalDOMWindow& Window(); 40 SimPage& GetPage(); 41 Document& GetDocument(); 42 WebViewImpl& WebView(); 43 WebLocalFrameImpl& MainFrame(); 44 WebLocalFrameImpl& LocalFrameRoot(); 45 frame_test_helpers::TestWebViewClient& WebViewClient(); 46 frame_test_helpers::TestWebWidgetClient& WebWidgetClient(); 47 frame_test_helpers::TestWebFrameClient& WebFrameClient(); 48 SimCompositor& Compositor(); 49 50 Vector<String>& ConsoleMessages(); 51 52 private: 53 // These are unique_ptrs in order to destroy them in TearDown. Subclasses 54 // may override Platform::Current() and these must shutdown before the 55 // subclass destructor. 56 std::unique_ptr<SimNetwork> network_; 57 std::unique_ptr<SimCompositor> compositor_; 58 std::unique_ptr<frame_test_helpers::TestWebFrameClient> web_frame_client_; 59 std::unique_ptr<frame_test_helpers::TestWebViewClient> web_view_client_; 60 std::unique_ptr<SimPage> page_; 61 std::unique_ptr<frame_test_helpers::WebViewHelper> web_view_helper_; 62 UntracedMember<WebLocalFrameImpl> local_frame_root_; 63 }; 64 65 } // namespace blink 66 67 #endif 68