Flutter Engine
 
Loading...
Searching...
No Matches
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 107 of file android_context_gl_unittests.cc.

107 {
108 GrMockOptions main_context_options;
109 sk_sp<GrDirectContext> main_context =
110 GrDirectContext::MakeMock(&main_context_options);
111 auto environment = fml::MakeRefCounted<AndroidEnvironmentGL>();
112 std::string thread_label =
113 ::testing::UnitTest::GetInstance()->current_test_info()->name();
114
116 thread_label, ThreadHost::Type::kUi | ThreadHost::Type::kRaster |
117 ThreadHost::Type::kIo));
118 TaskRunners task_runners = MakeTaskRunners(thread_label, thread_host);
119 auto context =
120 std::make_unique<AndroidContextGLSkia>(environment, task_runners);
121 context->SetMainSkiaContext(main_context);
122 EXPECT_NE(context.get(), nullptr);
123 context.reset();
124 EXPECT_TRUE(main_context->abandoned());
125}
The collection of all the threads used by the engine.
Definition thread_host.h:21

References flutter::ThreadHost::kIo, flutter::ThreadHost::kRaster, and flutter::ThreadHost::kUi.

◆ TEST() [2/6]

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

Definition at line 127 of file android_context_gl_unittests.cc.

127 {
128 auto impeller_context = std::make_shared<TestImpellerContext>();
129 auto android_context = std::make_unique<TestAndroidContext>(
130 impeller_context, AndroidRenderingAPI::kImpellerOpenGLES);
131 EXPECT_FALSE(impeller_context->did_shutdown);
132
133 android_context.reset();
134
135 EXPECT_TRUE(impeller_context->did_shutdown);
136}

References flutter::kImpellerOpenGLES.

◆ TEST() [3/6]

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

Definition at line 138 of file android_context_gl_unittests.cc.

138 {
139 GrMockOptions main_context_options;
140 sk_sp<GrDirectContext> main_context =
141 GrDirectContext::MakeMock(&main_context_options);
142 auto environment = fml::MakeRefCounted<AndroidEnvironmentGL>();
143 std::string thread_label =
144 ::testing::UnitTest::GetInstance()->current_test_info()->name();
146 fml::RefPtr<fml::TaskRunner> platform_runner =
148 TaskRunners task_runners =
149 TaskRunners(thread_label, platform_runner, platform_runner,
150 platform_runner, platform_runner);
151 auto context =
152 std::make_unique<AndroidContextGLSkia>(environment, task_runners);
153 context->SetMainSkiaContext(main_context);
154 EXPECT_NE(context.get(), nullptr);
155 context.reset();
156 EXPECT_TRUE(main_context->abandoned());
157}
static void EnsureInitializedForCurrentThread()
fml::RefPtr< fml::TaskRunner > GetTaskRunner() const
static FML_EMBEDDER_ONLY MessageLoop & GetCurrent()

References fml::MessageLoop::EnsureInitializedForCurrentThread(), fml::MessageLoop::GetCurrent(), and fml::MessageLoop::GetTaskRunner().

◆ TEST() [4/6]

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

Definition at line 206 of file android_context_gl_unittests.cc.

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

References flutter::ThreadHost::kIo, flutter::ThreadHost::kRaster, flutter::kSuccessAlreadyCurrent, flutter::kSuccessMadeCurrent, and flutter::ThreadHost::kUi.

◆ TEST() [5/6]

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

Definition at line 159 of file android_context_gl_unittests.cc.

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

References flutter::ThreadHost::kIo, flutter::ThreadHost::kRaster, flutter::ThreadHost::kUi, and window.

◆ TEST() [6/6]

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

Definition at line 183 of file android_context_gl_unittests.cc.

183 {
184 GrMockOptions main_context_options;
185 sk_sp<GrDirectContext> main_context =
186 GrDirectContext::MakeMock(&main_context_options);
187 auto environment = fml::MakeRefCounted<AndroidEnvironmentGL>();
188 std::string thread_label =
189 ::testing::UnitTest::GetInstance()->current_test_info()->name();
190
191 auto mask =
192 ThreadHost::Type::kUi | ThreadHost::Type::kRaster | ThreadHost::Type::kIo;
194
195 ThreadHost thread_host(host_config);
196 TaskRunners task_runners = MakeTaskRunners(thread_label, thread_host);
197 auto android_context =
198 std::make_shared<AndroidContextGLSkia>(environment, task_runners);
199 auto android_surface =
200 std::make_unique<AndroidSurfaceGLSkia>(android_context);
201 EXPECT_EQ(android_surface->GetOnscreenSurface(), nullptr);
202 android_surface->CreateSnapshotSurface();
203 EXPECT_NE(android_surface->GetOnscreenSurface(), nullptr);
204}

References flutter::ThreadHost::kIo, flutter::ThreadHost::kRaster, and flutter::ThreadHost::kUi.