File: lottie_test_data.h

package info (click to toggle)
chromium 139.0.7258.127-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 6,122,068 kB
  • sloc: cpp: 35,100,771; ansic: 7,163,530; javascript: 4,103,002; python: 1,436,920; asm: 946,517; xml: 746,709; pascal: 187,653; perl: 88,691; sh: 88,436; objc: 79,953; sql: 51,488; cs: 44,583; fortran: 24,137; makefile: 22,147; tcl: 15,277; php: 13,980; yacc: 8,984; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (368 lines) | stat: -rw-r--r-- 8,216 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
// Copyright 2021 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CC_TEST_LOTTIE_TEST_DATA_H_
#define CC_TEST_LOTTIE_TEST_DATA_H_

#include <string>
#include <string_view>

#include "base/files/file_path.h"
#include "base/time/time.h"
#include "third_party/skia/include/core/SkColor.h"
#include "ui/gfx/geometry/point_f.h"
#include "ui/gfx/geometry/rect_f.h"

namespace cc {

// A skottie animation with solid green color for the first 2.5 seconds and then
// a solid blue color for the next 2.5 seconds.
constexpr std::string_view kLottieDataWithoutAssets1 =
    R"({
      "v" : "4.12.0",
      "fr": 30,
      "w" : 400,
      "h" : 200,
      "ip": 0,
      "op": 150,
      "assets": [],
      "layers": [
        {
          "nm": "Color 1",
          "ty": 1,
          "sw": 400,
          "sh": 200,
          "sc": "#00ff00",
          "ip": 0,
          "op": 75
        },
        {
          "nm": "Color 2",
          "ty": 1,
          "sw": 400,
          "sh": 200,
          "sc": "#0000ff",
          "ip": 76,
          "op": 150
        }
      ]
    })";

constexpr std::string_view kLottieDataWithoutAssets1Color1Node = "Color 1";
constexpr std::string_view kLottieDataWithoutAssets1Color2Node = "Color 2";
constexpr SkColor kLottieDataWithoutAssets1Color1 = SK_ColorGREEN;
constexpr SkColor kLottieDataWithoutAssets1Color2 = SK_ColorBLUE;

// Returns an animation with the same structure as |kLottieDataWithoutAssets1|
// except with color node names specified by the caller.
std::string CreateCustomLottieDataWith2ColorNodes(
    std::string_view color_node_1,
    std::string_view color_node_2);

// A skottie animation with solid green color for the first second and then
// a solid blue color for the next second.
constexpr std::string_view kLottieDataWithoutAssets2 =
    R"({
      "v" : "4.12.0",
      "fr": 30,
      "w" : 400,
      "h" : 200,
      "ip": 0,
      "op": 60,
      "assets": [],
      "layers": [
        {
          "ty": 1,
          "sw": 400,
          "sh": 200,
          "sc": "#00ff00",
          "ip": 0,
          "op": 30
        },
        {
          "ty": 1,
          "sw": 400,
          "sh": 200,
          "sc": "#0000ff",
          "ip": 31,
          "op": 60
        }
      ]
    })";

// A test animation generated in Adobe AE that displays image_0 for a second,
// then image_1 for another second.
constexpr int kLottieDataWith2AssetsWidth = 690;
constexpr int kLottieDataWith2AssetsHeight = 455;
constexpr base::TimeDelta kLottieDataWith2AssetsDuration = base::Seconds(2);
constexpr std::string_view kLottieDataWith2Assets =
    R"({
  "v": "5.7.4",
  "fr": 60,
  "ip": 0,
  "op": 119,
  "w": 690,
  "h": 455,
  "nm": "2 photo - Cut",
  "ddd": 0,
  "assets": [
    {
      "id": "image_0",
      "w": 690,
      "h": 455,
      "u": "images/",
      "p": "img_0.jpg",
      "e": 0
    },
    {
      "id": "image_1",
      "w": 690,
      "h": 455,
      "u": "images/",
      "p": "img_1.jpg",
      "e": 0
    }
  ],
  "layers": [
    {
      "ddd": 0,
      "ind": 1,
      "ty": 2,
      "nm": "CODERED_B1_landscape_P2a_690x455.jpg.img.jpg",
      "cl": "jpg img jpg",
      "refId": "image_0",
      "sr": 1,
      "ks": {
        "o": {
          "a": 0,
          "k": 100,
          "ix": 11
        },
        "r": {
          "a": 0,
          "k": 0,
          "ix": 10
        },
        "p": {
          "a": 0,
          "k": [
            345,
            227.5,
            0
          ],
          "ix": 2,
          "l": 2
        },
        "a": {
          "a": 0,
          "k": [
            345,
            227.5,
            0
          ],
          "ix": 1,
          "l": 2
        },
        "s": {
          "a": 0,
          "k": [
            100,
            100,
            100
          ],
          "ix": 6,
          "l": 2
        }
      },
      "ao": 0,
      "ip": 0,
      "op": 61,
      "st": 0,
      "bm": 0
    },
    {
      "ddd": 0,
      "ind": 2,
      "ty": 2,
      "nm": "CODERED_B1_landscape_P2b_690x455.jpg.img.jpg",
      "cl": "jpg img jpg",
      "refId": "image_1",
      "sr": 1,
      "ks": {
        "o": {
          "a": 0,
          "k": 100,
          "ix": 11
        },
        "r": {
          "a": 0,
          "k": 0,
          "ix": 10
        },
        "p": {
          "a": 0,
          "k": [
            345,
            227.5,
            0
          ],
          "ix": 2,
          "l": 2
        },
        "a": {
          "a": 0,
          "k": [
            345,
            227.5,
            0
          ],
          "ix": 1,
          "l": 2
        },
        "s": {
          "a": 0,
          "k": [
            100,
            100,
            100
          ],
          "ix": 6,
          "l": 2
        }
      },
      "ao": 0,
      "ip": 61,
      "op": 120,
      "st": 61,
      "bm": 0
    },
    {
      "ddd": 0,
      "ind": 3,
      "ty": 1,
      "nm": "White Solid 2",
      "sr": 1,
      "ks": {
        "o": {
          "a": 0,
          "k": 100,
          "ix": 11
        },
        "r": {
          "a": 0,
          "k": 0,
          "ix": 10
        },
        "p": {
          "a": 0,
          "k": [
            345,
            227.5,
            0
          ],
          "ix": 2,
          "l": 2
        },
        "a": {
          "a": 0,
          "k": [
            345,
            227.5,
            0
          ],
          "ix": 1,
          "l": 2
        },
        "s": {
          "a": 0,
          "k": [
            100,
            100,
            100
          ],
          "ix": 6,
          "l": 2
        }
      },
      "ao": 0,
      "sw": 690,
      "sh": 455,
      "sc": "#ffffff",
      "ip": 0,
      "op": 1769,
      "st": 0,
      "bm": 0
    }
  ],
  "markers": []
})";

// Returns an animation with the same structure as |kLottieDataWith2Assets|
// except with asset ids specified by the caller.
std::string CreateCustomLottieDataWith2Assets(
    std::string_view custom_asset_id_0,
    std::string_view custom_asset_id_1);

// cc/test/data/lottie/animation_with_2_text_nodes.json
constexpr base::FilePath::CharType kLottieDataWith2TextFileName[] =
    FILE_PATH_LITERAL("animation_with_2_text_nodes.json");
constexpr std::string_view kLottieDataWith2TextNode1 = "text_node_1";
constexpr std::string_view kLottieDataWith2TextNode1Text = "test_text_1";
constexpr std::string_view kLottieDataWith2TextNode2 = "text_node_2";
constexpr std::string_view kLottieDataWith2TextNode2Text = "test_text_2";
constexpr gfx::RectF kLottieDataWith2TextNode1Box =
    gfx::RectF(10, 20, 100, 200);
constexpr gfx::RectF kLottieDataWith2TextNode2Box =
    gfx::RectF(20, 40, 200, 400);
constexpr gfx::PointF kLottieDataWith2TextNode1Position = gfx::PointF(100, 200);
constexpr gfx::PointF kLottieDataWith2TextNode2Position = gfx::PointF(200, 400);

// Returns an animation with the same structure as
// |kLottieDataWith2TextFileName| except with text node names specified by the
// caller.
std::string CreateCustomLottieDataWith2TextNodes(
    std::string_view custom_text_node_name_0,
    std::string_view custom_text_node_name_1);

constexpr std::string_view kLottieDataWith2MarkersMarker1 = "TestMarker1";
constexpr std::string_view kLottieDataWith2MarkersMarker2 = "TestMarker2";
constexpr float kLottieDataWith2MarkersMarker1Time = .33f;
constexpr float kLottieDataWith2MarkersMarker2Time = .67f;
// Duration: 6 seconds. Marker 1 is at 2 seconds, and marker 2 is at 4 seconds.
constexpr std::string_view kLottieDataWith2Markers =
    R"({
      "v" : "4.12.0",
      "fr": 30,
      "w" : 400,
      "h" : 200,
      "ip": 0,
      "op": 180,
      "assets": [],
      "layers": [
        {
          "ty": 1,
          "sw": 400,
          "sh": 200,
          "sc": "#00ff00",
          "ip": 0,
          "op": 180
        }
      ],
      "markers": [
        {
          "tm": 60,
          "cm": "TestMarker1",
          "dr": 0
        },
        {
          "tm": 120,
          "cm": "TestMarker2",
          "dr": 0
        }
      ]
    })";

}  // namespace cc

#endif  // CC_TEST_LOTTIE_TEST_DATA_H_