Flutter Engine
The Flutter Engine
Functions
AudioLayer.cpp File Reference
#include "include/core/SkStream.h"
#include "modules/skottie/include/Skottie.h"
#include "tests/Test.h"

Go to the source code of this file.

Functions

 DEF_TEST (Skottie_AudioLayer, r)
 

Function Documentation

◆ DEF_TEST()

DEF_TEST ( Skottie_AudioLayer  ,
 
)

Definition at line 15 of file AudioLayer.cpp.

15 {
16 static constexpr char json[] =
17 R"({
18 "v": "5.2.1",
19 "w": 100,
20 "h": 100,
21 "fr": 10,
22 "ip": 0,
23 "op": 100,
24 "assets": [
25 {
26 "id": "audio_0",
27 "p" : "audio.mp3",
28 "u" : "assets/"
29 }
30 ],
31 "layers": [
32 {
33 "ty" : 6,
34 "ind" : 0,
35 "ip" : 20,
36 "op" : 70,
37 "refId": "audio_0"
38 },
39 {
40 "ty" : 6,
41 "ind" : 0,
42 "ip" : 50,
43 "op" : 80,
44 "refId": "audio_0"
45 },
46 {
47 "ty": 1,
48 "ip": 0,
49 "op": 100,
50 "sw": 100,
51 "sh": 100,
52 "sc": "#ffffff"
53 }
54 ]
55 })";
56
57 class MockTracker final : public ExternalTrackAsset {
58 public:
59 bool isPlaying() const { return fCurrentTime >= 0; }
60 float currentTime() const { return fCurrentTime; }
61
62 private:
63 void seek(float t) override {
64 fCurrentTime = t;
65 }
66
67 float fCurrentTime = 0;
68 };
69
70 class MockResourceProvider final : public ResourceProvider {
71 public:
72 explicit MockResourceProvider(skiatest::Reporter* r) : fReporter(r) {}
73
74 const std::vector<sk_sp<MockTracker>>& tracks() const { return fTracks; }
75
76 private:
78 const char name[],
79 const char id[]) override {
80 REPORTER_ASSERT(fReporter, !strcmp(path, "assets/"));
81 REPORTER_ASSERT(fReporter, !strcmp(name, "audio.mp3"));
82 REPORTER_ASSERT(fReporter, !strcmp(id , "audio_0"));
83
84 fTracks.push_back(sk_make_sp<MockTracker>());
85
86 return fTracks.back();
87 }
88
89 skiatest::Reporter* fReporter;
90 std::vector<sk_sp<MockTracker>> fTracks;
91 };
92
93 SkMemoryStream stream(json, strlen(json));
94 auto rp = sk_make_sp<MockResourceProvider>(r);
95
#define REPORTER_ASSERT(r, cond,...)
Definition: Test.h:286
virtual void seek(float t)=0
virtual sk_sp< ExternalTrackAsset > loadAudioAsset(const char[], const char[], const char[])
Definition: SkResources.h:174
DlVertices::Builder Builder
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
Definition: switches.h:57
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32