Flutter Engine
The Flutter Engine
gtest_activity.cc
Go to the documentation of this file.
1// Copyright 2013 The Flutter 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#include "flutter/testing/android/native_activity/gtest_activity.h"
6
7#include "flutter/impeller/toolkit/android/native_window.h"
8#include "flutter/testing/logger_listener.h"
9#include "flutter/testing/test_timeout_listener.h"
10
11namespace flutter {
12
13GTestActivity::GTestActivity(ANativeActivity* activity)
14 : NativeActivity(activity) {}
15
17
19 auto timeout_listener = new flutter::testing::TestTimeoutListener(
21 auto logger_listener = new flutter::testing::LoggerListener();
22
23 auto& listeners = ::testing::UnitTest::GetInstance()->listeners();
24
25 listeners.Append(timeout_listener);
26 listeners.Append(logger_listener);
27
28 int result = RUN_ALL_TESTS();
29
30 delete listeners.Release(timeout_listener);
31 delete listeners.Release(logger_listener);
32
33 FML_CHECK(result == 0);
34}
35
36// |NativeActivity|
38 auto handle = std::make_shared<impeller::android::NativeWindow>(window);
39 background_thread_.GetTaskRunner()->PostTask(
40 [handle]() { StartTestSuite(*handle); });
41}
42
43std::unique_ptr<NativeActivity> NativeActivityMain(
44 ANativeActivity* activity,
45 std::unique_ptr<fml::Mapping> saved_state) {
46 return std::make_unique<GTestActivity>(activity);
47}
48
49} // namespace flutter
GTestActivity(ANativeActivity *activity)
void OnNativeWindowCreated(ANativeWindow *window) override
An instance of a native activity. Users of the native_activity_apk are meant to subclass this and ret...
virtual void PostTask(const fml::closure &task) override
Definition: task_runner.cc:24
fml::RefPtr< fml::TaskRunner > GetTaskRunner() const
Definition: thread.cc:164
static constexpr TimeDelta FromSeconds(int64_t seconds)
Definition: time_delta.h:49
A wrapper for ANativeWindow https://developer.android.com/ndk/reference/group/a-native-window.
Definition: native_window.h:20
GLFWwindow * window
Definition: main.cc:45
GAsyncResult * result
#define FML_CHECK(condition)
Definition: logging.h:85
std::unique_ptr< NativeActivity > NativeActivityMain(ANativeActivity *activity, std::unique_ptr< fml::Mapping > saved_state)
static void StartTestSuite(const impeller::android::NativeWindow &window)
void * saved_state
struct ANativeWindow ANativeWindow