1 // Copyright 2019 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 COMPONENTS_EXO_WAYLAND_FUZZER_SERVER_ENVIRONMENT_H_
6 #define COMPONENTS_EXO_WAYLAND_FUZZER_SERVER_ENVIRONMENT_H_
7 
8 #include "base/test/task_environment.h"
9 #include "base/threading/thread.h"
10 #include "components/exo/wayland/clients/test/wayland_client_test_helper.h"
11 #include "ui/aura/env.h"
12 
13 namespace exo {
14 namespace wayland_fuzzer {
15 
16 // The wayland fuzzer is pretending to be a client, and the ServerEnvironment is
17 // used to bring up that client's server. This sets up the major components of
18 // the test environment, including initializing the display, running the server
19 // in a thread, etc.
20 //
21 // For performance reasons, the server should be retained between runs of the
22 // fuzzer, though this has the unfortunate consequence that fuzzer runs retain
23 // state which may cause non-reproducible crashes.
24 class ServerEnvironment : public WaylandClientTestHelper {
25  public:
26   ServerEnvironment();
27 
28   ~ServerEnvironment() override;
29 
30   void SetUpOnUIThread(base::WaitableEvent* event) override;
31 
32  private:
33   std::unique_ptr<aura::Env> env_;
34   base::test::TaskEnvironment task_environment_;
35   base::Thread ui_thread_;
36 };
37 
38 }  // namespace wayland_fuzzer
39 }  // namespace exo
40 
41 #endif  // COMPONENTS_EXO_WAYLAND_FUZZER_SERVER_ENVIRONMENT_H_
42