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   void LoadURL(const String& url);
31 
32   // WebView is created after SetUp to allow test to customize
33   // web runtime features.
34   // These methods should be accessed inside test body after a call to SetUp.
35   LocalDOMWindow& Window();
36   SimPage& GetPage();
37   Document& GetDocument();
38   WebViewImpl& WebView();
39   WebLocalFrameImpl& MainFrame();
40   frame_test_helpers::TestWebViewClient& WebViewClient();
41   frame_test_helpers::TestWebWidgetClient& WebWidgetClient();
42   frame_test_helpers::TestWebFrameClient& WebFrameClient();
43   SimCompositor& Compositor();
44 
45   Vector<String>& ConsoleMessages();
46 
47  private:
48   // These are unique_ptrs in order to destroy them in TearDown. Subclasses
49   // may override Platform::Current() and these must shutdown before the
50   // subclass destructor.
51   std::unique_ptr<SimNetwork> network_;
52   std::unique_ptr<SimCompositor> compositor_;
53   std::unique_ptr<frame_test_helpers::TestWebFrameClient> web_frame_client_;
54   std::unique_ptr<frame_test_helpers::TestWebViewClient> web_view_client_;
55   std::unique_ptr<SimPage> page_;
56   std::unique_ptr<frame_test_helpers::WebViewHelper> web_view_helper_;
57 };
58 
59 }  // namespace blink
60 
61 #endif
62