Centralize legacy recording bridge
This commit is contained in:
@@ -2,9 +2,75 @@
|
||||
#include "test_harness.h"
|
||||
|
||||
#include <limits>
|
||||
#include <string>
|
||||
|
||||
namespace {
|
||||
|
||||
class FakeRecordingServices final : public pp::app::RecordingServices {
|
||||
public:
|
||||
void start_thread() override
|
||||
{
|
||||
starts += 1;
|
||||
call_order += "start;";
|
||||
}
|
||||
|
||||
void stop_thread() override
|
||||
{
|
||||
stops += 1;
|
||||
call_order += "stop;";
|
||||
}
|
||||
|
||||
void delete_recorded_files() override
|
||||
{
|
||||
deletes += 1;
|
||||
call_order += "delete;";
|
||||
}
|
||||
|
||||
void set_frame_count(int frame_count) override
|
||||
{
|
||||
frame_count_value = frame_count;
|
||||
call_order += "count;";
|
||||
}
|
||||
|
||||
void update_frame_label() override
|
||||
{
|
||||
label_updates += 1;
|
||||
call_order += "label;";
|
||||
}
|
||||
|
||||
void begin_export(int progress_total) override
|
||||
{
|
||||
export_begins += 1;
|
||||
export_progress_total = progress_total;
|
||||
call_order += "begin;";
|
||||
}
|
||||
|
||||
void write_mp4(std::string_view path) override
|
||||
{
|
||||
export_writes += 1;
|
||||
export_path = std::string(path);
|
||||
call_order += "write;";
|
||||
}
|
||||
|
||||
void end_export() override
|
||||
{
|
||||
export_ends += 1;
|
||||
call_order += "end;";
|
||||
}
|
||||
|
||||
int starts = 0;
|
||||
int stops = 0;
|
||||
int deletes = 0;
|
||||
int label_updates = 0;
|
||||
int frame_count_value = -1;
|
||||
int export_begins = 0;
|
||||
int export_writes = 0;
|
||||
int export_ends = 0;
|
||||
int export_progress_total = 0;
|
||||
std::string export_path;
|
||||
std::string call_order;
|
||||
};
|
||||
|
||||
void recording_start_only_starts_when_not_running(pp::tests::Harness& harness)
|
||||
{
|
||||
PP_EXPECT(
|
||||
@@ -53,6 +119,55 @@ void recording_export_clamps_progress_total(pp::tests::Harness& harness)
|
||||
PP_EXPECT(harness, plan.progress_total == std::numeric_limits<int>::max());
|
||||
}
|
||||
|
||||
void executor_dispatches_recording_lifecycle(pp::tests::Harness& harness)
|
||||
{
|
||||
FakeRecordingServices services;
|
||||
|
||||
PP_EXPECT(
|
||||
harness,
|
||||
pp::app::execute_recording_start_action(pp::app::RecordingStartAction::start_thread, services).ok());
|
||||
PP_EXPECT(
|
||||
harness,
|
||||
pp::app::execute_recording_stop_action(pp::app::RecordingStopAction::stop_thread, services).ok());
|
||||
PP_EXPECT(
|
||||
harness,
|
||||
pp::app::execute_recording_start_action(
|
||||
pp::app::RecordingStartAction::no_op_already_running,
|
||||
services)
|
||||
.ok());
|
||||
PP_EXPECT(
|
||||
harness,
|
||||
pp::app::execute_recording_stop_action(pp::app::RecordingStopAction::no_op_not_running, services).ok());
|
||||
|
||||
PP_EXPECT(harness, services.starts == 1);
|
||||
PP_EXPECT(harness, services.stops == 1);
|
||||
PP_EXPECT(harness, services.call_order == "start;stop;");
|
||||
}
|
||||
|
||||
void executor_dispatches_recording_clear_and_export(pp::tests::Harness& harness)
|
||||
{
|
||||
FakeRecordingServices services;
|
||||
|
||||
const auto clear = pp::app::plan_recording_clear(true, true);
|
||||
PP_EXPECT(harness, pp::app::execute_recording_clear_plan(clear, services).ok());
|
||||
|
||||
const auto export_plan = pp::app::plan_recording_export(12);
|
||||
PP_EXPECT(
|
||||
harness,
|
||||
pp::app::execute_recording_export_plan(export_plan, services, "D:/Paint/out.mp4").ok());
|
||||
|
||||
PP_EXPECT(harness, services.stops == 1);
|
||||
PP_EXPECT(harness, services.deletes == 1);
|
||||
PP_EXPECT(harness, services.frame_count_value == 0);
|
||||
PP_EXPECT(harness, services.label_updates == 1);
|
||||
PP_EXPECT(harness, services.export_begins == 1);
|
||||
PP_EXPECT(harness, services.export_progress_total == 12);
|
||||
PP_EXPECT(harness, services.export_writes == 1);
|
||||
PP_EXPECT(harness, services.export_path == "D:/Paint/out.mp4");
|
||||
PP_EXPECT(harness, services.export_ends == 1);
|
||||
PP_EXPECT(harness, services.call_order == "stop;delete;count;label;begin;write;end;");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int main()
|
||||
@@ -65,5 +180,7 @@ int main()
|
||||
recording_clear_resets_frames_and_preserves_platform_delete_flag);
|
||||
harness.run("recording export tracks frame count", recording_export_tracks_frame_count);
|
||||
harness.run("recording export clamps progress total", recording_export_clamps_progress_total);
|
||||
harness.run("executor dispatches recording lifecycle", executor_dispatches_recording_lifecycle);
|
||||
harness.run("executor dispatches recording clear and export", executor_dispatches_recording_clear_and_export);
|
||||
return harness.finish();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user