Flutter Engine
The Flutter Engine
Classes | Functions
flutter::testing::android Namespace Reference

Classes

class  TestAndroidContext
 
class  TestImpellerContext
 

Functions

 TEST (AndroidContextGl, Create)
 
 TEST (AndroidContextGl, CreateImpeller)
 
 TEST (AndroidContextGl, CreateSingleThread)
 
 TEST (AndroidSurfaceGL, CreateSnapshopSurfaceWhenOnscreenSurfaceIsNotNull)
 
 TEST (AndroidSurfaceGL, CreateSnapshopSurfaceWhenOnscreenSurfaceIsNull)
 
 TEST (AndroidContextGl, EnsureMakeCurrentChecksCurrentContextStatus)
 

Function Documentation

◆ TEST() [1/6]

flutter::testing::android::TEST ( AndroidContextGl  ,
Create   
)

Definition at line 99 of file android_context_gl_unittests.cc.

99 {
100 GrMockOptions main_context_options;
101 sk_sp<GrDirectContext> main_context =
102 GrDirectContext::MakeMock(&main_context_options);
103 auto environment = fml::MakeRefCounted<AndroidEnvironmentGL>();
104 std::string thread_label =
105 ::testing::UnitTest::GetInstance()->current_test_info()->name();
106
108 thread_label, ThreadHost::Type::kUi | ThreadHost::Type::kRaster |
109 ThreadHost::Type::kIo));
110 TaskRunners task_runners = MakeTaskRunners(thread_label, thread_host);
111 auto context =
112 std::make_unique<AndroidContextGLSkia>(environment, task_runners);
113 context->SetMainSkiaContext(main_context);
114 EXPECT_NE(context.get(), nullptr);
115 context.reset();
116 EXPECT_TRUE(main_context->abandoned());
117}
static sk_sp< GrDirectContext > MakeMock(const GrMockOptions *, const GrContextOptions &)
bool abandoned() override
@ kRaster
Suitable for thread which raster data.
Definition: embedder.h:266
static dart::SimpleHashMap * environment
Definition: gen_snapshot.cc:59
The collection of all the threads used by the engine.
Definition: thread_host.h:21
#define EXPECT_TRUE(handle)
Definition: unit_test.h:678

◆ TEST() [2/6]

flutter::testing::android::TEST ( AndroidContextGl  ,
CreateImpeller   
)

Definition at line 119 of file android_context_gl_unittests.cc.

119 {
120 auto impeller_context = std::make_shared<TestImpellerContext>();
121 auto android_context = std::make_unique<TestAndroidContext>(
122 impeller_context, AndroidRenderingAPI::kImpellerOpenGLES);
123 EXPECT_FALSE(impeller_context->did_shutdown);
124
125 android_context.reset();
126
127 EXPECT_TRUE(impeller_context->did_shutdown);
128}

◆ TEST() [3/6]

flutter::testing::android::TEST ( AndroidContextGl  ,
CreateSingleThread   
)

Definition at line 130 of file android_context_gl_unittests.cc.

130 {
131 GrMockOptions main_context_options;
132 sk_sp<GrDirectContext> main_context =
133 GrDirectContext::MakeMock(&main_context_options);
134 auto environment = fml::MakeRefCounted<AndroidEnvironmentGL>();
135 std::string thread_label =
136 ::testing::UnitTest::GetInstance()->current_test_info()->name();
138 fml::RefPtr<fml::TaskRunner> platform_runner =
140 TaskRunners task_runners =
141 TaskRunners(thread_label, platform_runner, platform_runner,
142 platform_runner, platform_runner);
143 auto context =
144 std::make_unique<AndroidContextGLSkia>(environment, task_runners);
145 context->SetMainSkiaContext(main_context);
146 EXPECT_NE(context.get(), nullptr);
147 context.reset();
148 EXPECT_TRUE(main_context->abandoned());
149}
static void EnsureInitializedForCurrentThread()
Definition: message_loop.cc:27
fml::RefPtr< fml::TaskRunner > GetTaskRunner() const
Definition: message_loop.cc:56
static FML_EMBEDDER_ONLY MessageLoop & GetCurrent()
Definition: message_loop.cc:19

◆ TEST() [4/6]

flutter::testing::android::TEST ( AndroidContextGl  ,
EnsureMakeCurrentChecksCurrentContextStatus   
)

Definition at line 198 of file android_context_gl_unittests.cc.

198 {
199 GrMockOptions main_context_options;
200 sk_sp<GrDirectContext> main_context =
201 GrDirectContext::MakeMock(&main_context_options);
202 auto environment = fml::MakeRefCounted<AndroidEnvironmentGL>();
203 std::string thread_label =
204 ::testing::UnitTest::GetInstance()->current_test_info()->name();
205
207 thread_label, ThreadHost::Type::kUi | ThreadHost::Type::kRaster |
208 ThreadHost::Type::kIo));
209 TaskRunners task_runners = MakeTaskRunners(thread_label, thread_host);
210 auto context =
211 std::make_unique<AndroidContextGLSkia>(environment, task_runners);
212
213 auto pbuffer_surface = context->CreatePbufferSurface();
214 auto status = pbuffer_surface->MakeCurrent();
215 EXPECT_EQ(AndroidEGLSurfaceMakeCurrentStatus::kSuccessMadeCurrent, status);
216
217 // context already current, so status must reflect that.
218 status = pbuffer_surface->MakeCurrent();
219 EXPECT_EQ(AndroidEGLSurfaceMakeCurrentStatus::kSuccessAlreadyCurrent, status);
220}

◆ TEST() [5/6]

flutter::testing::android::TEST ( AndroidSurfaceGL  ,
CreateSnapshopSurfaceWhenOnscreenSurfaceIsNotNull   
)

Definition at line 151 of file android_context_gl_unittests.cc.

151 {
152 GrMockOptions main_context_options;
153 sk_sp<GrDirectContext> main_context =
154 GrDirectContext::MakeMock(&main_context_options);
155 auto environment = fml::MakeRefCounted<AndroidEnvironmentGL>();
156 std::string thread_label =
157 ::testing::UnitTest::GetInstance()->current_test_info()->name();
159 thread_label, ThreadHost::Type::kUi | ThreadHost::Type::kRaster |
160 ThreadHost::Type::kIo));
161 TaskRunners task_runners = MakeTaskRunners(thread_label, thread_host);
162 auto android_context =
163 std::make_shared<AndroidContextGLSkia>(environment, task_runners);
164 auto android_surface =
165 std::make_unique<AndroidSurfaceGLSkia>(android_context);
166 auto window = fml::MakeRefCounted<AndroidNativeWindow>(
167 nullptr, /*is_fake_window=*/true);
168 android_surface->SetNativeWindow(window);
169 auto onscreen_surface = android_surface->GetOnscreenSurface();
170 EXPECT_NE(onscreen_surface, nullptr);
171 android_surface->CreateSnapshotSurface();
172 EXPECT_EQ(onscreen_surface, android_surface->GetOnscreenSurface());
173}
GLFWwindow * window
Definition: main.cc:45

◆ TEST() [6/6]

flutter::testing::android::TEST ( AndroidSurfaceGL  ,
CreateSnapshopSurfaceWhenOnscreenSurfaceIsNull   
)

Definition at line 175 of file android_context_gl_unittests.cc.

175 {
176 GrMockOptions main_context_options;
177 sk_sp<GrDirectContext> main_context =
178 GrDirectContext::MakeMock(&main_context_options);
179 auto environment = fml::MakeRefCounted<AndroidEnvironmentGL>();
180 std::string thread_label =
181 ::testing::UnitTest::GetInstance()->current_test_info()->name();
182
183 auto mask =
184 ThreadHost::Type::kUi | ThreadHost::Type::kRaster | ThreadHost::Type::kIo;
186
187 ThreadHost thread_host(host_config);
188 TaskRunners task_runners = MakeTaskRunners(thread_label, thread_host);
189 auto android_context =
190 std::make_shared<AndroidContextGLSkia>(environment, task_runners);
191 auto android_surface =
192 std::make_unique<AndroidSurfaceGLSkia>(android_context);
193 EXPECT_EQ(android_surface->GetOnscreenSurface(), nullptr);
194 android_surface->CreateSnapshotSurface();
195 EXPECT_NE(android_surface->GetOnscreenSurface(), nullptr);
196}