Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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, DISABLED_MSAAx4)
 
 TEST (AndroidContextGl, EnsureMakeCurrentChecksCurrentContextStatus)
 

Function Documentation

◆ TEST() [1/7]

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, 0);
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 &)
The collection of all the threads used by the engine.
Definition thread_host.h:21
#define EXPECT_TRUE(handle)
Definition unit_test.h:685

◆ TEST() [2/7]

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/7]

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, 0);
145 context->SetMainSkiaContext(main_context);
146 EXPECT_NE(context.get(), nullptr);
147 context.reset();
148 EXPECT_TRUE(main_context->abandoned());
149}
static void EnsureInitializedForCurrentThread()
fml::RefPtr< fml::TaskRunner > GetTaskRunner() const
static FML_EMBEDDER_ONLY MessageLoop & GetCurrent()

◆ TEST() [4/7]

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

Definition at line 199 of file android_context_gl_unittests.cc.

199 {
200 GrMockOptions main_context_options;
201 sk_sp<GrDirectContext> main_context =
202 GrDirectContext::MakeMock(&main_context_options);
203 auto environment = fml::MakeRefCounted<AndroidEnvironmentGL>();
204 std::string thread_label =
205 ::testing::UnitTest::GetInstance()->current_test_info()->name();
206
208 thread_label, ThreadHost::Type::kUi | ThreadHost::Type::kRaster |
209 ThreadHost::Type::kIo));
210 TaskRunners task_runners = MakeTaskRunners(thread_label, thread_host);
211 auto context =
212 std::make_unique<AndroidContextGLSkia>(environment, task_runners, 4);
213 context->SetMainSkiaContext(main_context);
214
215 EGLint sample_count;
216 eglGetConfigAttrib(environment->Display(), context->Config(), EGL_SAMPLES,
217 &sample_count);
218 EXPECT_EQ(sample_count, 4);
219}

◆ TEST() [5/7]

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

Definition at line 221 of file android_context_gl_unittests.cc.

221 {
222 GrMockOptions main_context_options;
223 sk_sp<GrDirectContext> main_context =
224 GrDirectContext::MakeMock(&main_context_options);
225 auto environment = fml::MakeRefCounted<AndroidEnvironmentGL>();
226 std::string thread_label =
227 ::testing::UnitTest::GetInstance()->current_test_info()->name();
228
230 thread_label, ThreadHost::Type::kUi | ThreadHost::Type::kRaster |
231 ThreadHost::Type::kIo));
232 TaskRunners task_runners = MakeTaskRunners(thread_label, thread_host);
233 auto context =
234 std::make_unique<AndroidContextGLSkia>(environment, task_runners, 0);
235
236 auto pbuffer_surface = context->CreatePbufferSurface();
237 auto status = pbuffer_surface->MakeCurrent();
238 EXPECT_EQ(AndroidEGLSurfaceMakeCurrentStatus::kSuccessMadeCurrent, status);
239
240 // context already current, so status must reflect that.
241 status = pbuffer_surface->MakeCurrent();
242 EXPECT_EQ(AndroidEGLSurfaceMakeCurrentStatus::kSuccessAlreadyCurrent, status);
243}

◆ TEST() [6/7]

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, 0);
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() [7/7]

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, 0);
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}