#ifndef FLUTTER_SHELL_COMMON_SHELL_TEST_H_
#define FLUTTER_SHELL_COMMON_SHELL_TEST_H_
#include <memory>
#include "flutter/common/settings.h"
#include "flutter/fml/macros.h"
#include "flutter/lib/ui/window/platform_message.h"
#include "flutter/shell/common/run_configuration.h"
#include "flutter/shell/common/shell.h"
#include "flutter/shell/common/thread_host.h"
#include "flutter/shell/gpu/gpu_surface_gl_delegate.h"
#include "flutter/testing/test_dart_native_resolver.h"
#include "flutter/testing/test_gl_surface.h"
#include "flutter/testing/thread_test.h"
namespace flutter {
namespace testing {
class ShellTest : public ThreadTest {
public:
ShellTest();
~ShellTest();
Settings CreateSettingsForFixture();
std::unique_ptr<Shell> CreateShell(Settings settings);
std::unique_ptr<Shell> CreateShell(Settings settings,
TaskRunners task_runners);
TaskRunners GetTaskRunnersForFixture();
void SendEnginePlatformMessage(Shell* shell,
fml::RefPtr<PlatformMessage> message);
void AddNativeCallback(std::string name, Dart_NativeFunction callback);
static void PlatformViewNotifyCreated(
Shell* shell);
static void RunEngine(Shell* shell, RunConfiguration configuration);
static void PumpOneFrame(Shell* shell);
static bool GetNeedsReportTimings(Shell* shell);
static void SetNeedsReportTimings(Shell* shell, bool value);
static int UnreportedTimingsCount(Shell* shell);
protected:
void SetUp() override;
void TearDown() override;
private:
fml::UniqueFD assets_dir_;
std::shared_ptr<TestDartNativeResolver> native_resolver_;
std::unique_ptr<ThreadHost> thread_host_;
void SetSnapshotsAndAssets(Settings& settings);
};
class ShellTestPlatformView : public PlatformView, public GPUSurfaceGLDelegate {
public:
ShellTestPlatformView(PlatformView::Delegate& delegate,
TaskRunners task_runners);
~ShellTestPlatformView() override;
private:
TestGLSurface gl_surface_;
std::unique_ptr<Surface> CreateRenderingSurface() override;
bool GLContextMakeCurrent() override;
bool GLContextClearCurrent() override;
bool GLContextPresent() override;
intptr_t GLContextFBO() const override;
GLProcResolver GetGLProcResolver() const override;
ExternalViewEmbedder* GetExternalViewEmbedder() override;
FML_DISALLOW_COPY_AND_ASSIGN(ShellTestPlatformView);
};
}
}
#endif