7#include "flutter/fml/message_loop_impl.h"
8#include "flutter/fml/thread.h"
9#include "flutter/shell/profiling/sampling_profiler.h"
10#include "flutter/testing/testing.h"
11#include "gmock/gmock.h"
20 inline static RefPtr<MockTaskRunner>
Create() {
21 return AdoptRef(
new MockTaskRunner());
23 MOCK_METHOD(
void, PostTask, (
const fml::closure& task), (
override));
32 MOCK_METHOD(
bool, RunsTasksOnCurrentThread, (), (
override));
33 MOCK_METHOD(TaskQueueId, GetTaskQueueId, (), (
override));
36 MockTaskRunner() : TaskRunner(
fml::RefPtr<MessageLoopImpl>()) {}
43TEST(SamplingProfilerTest, DeleteAfterStart) {
47 std::atomic<int> invoke_count = 0;
51 EXPECT_CALL(*task_runner, PostDelayedTask(_, _))
54 invoke_count.fetch_add(1);
55 thread->GetTaskRunner()->PostTask(task);
65 int invoke_count_at_delete = invoke_count.load();
66 std::this_thread::sleep_for(std::chrono::milliseconds(2));
67 ASSERT_EQ(invoke_count_at_delete, invoke_count.load());
static sk_sp< Effect > Create()
a Sampling Profiler that runs peridically and calls the Sampler which servers as a value function to ...
void Start()
Starts the SamplingProfiler by triggering SampleRepeatedly.
ObjectPtr Invoke(const Library &lib, const char *name)
std::string GetCurrentTestName()
Gets the name of the currently running test. This is useful in generating logs or assets based on tes...
TEST(FrameTimingsRecorderTest, RecordVsync)
RefPtr< T > AdoptRef(T *ptr)
std::function< void()> closure
Container for the metrics we collect during each run of Sampler. This currently holds CpuUsageInfo an...