1/*
2 * Copyright (C) 2022 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17syntax = "proto3";
18
19package test.screenshot.proto;
20option java_package = "platform.test.screenshot.proto";
21option java_outer_classname = "ScreenshotResultProto";
22
23message ComparisonOptions {
24  // Given an RGBA color, a failure will trigger if any channel changes beyond
25  // this specified threshold.
26  // Please only set this when actual inconsistencies are encountered.
27  // To find a reasonable value, consult the logs and see what real
28  // differences were encountered.  Anything above 4 is probably too much.
29  // Default: 0
30  int32 allowable_per_channel_difference = 5;
31
32  // Default: 0
33  int32 allowable_number_pixels_different = 3;
34
35  // Only compare pixels that have a nonzero alpha value in the reference image.
36  // Default: false
37  bool use_masking = 4;
38}
39
40message DiffRequest {
41  // PNG encoded image.
42  bytes image_test = 1;
43  oneof reference {
44    // Absolute file path, e.g.
45    // <RUNFILES>/google3/net/hostdatapath/common/statusz/scuba_goldens/header-1.png
46    // Use this when comparing a generated image against a golden image.
47    // An "Approve Changes" button will appear in the web UI.
48    string image_location_golden = 2;
49
50    // PNG encoded image. Use when comparing two generated images against each
51    // other.
52    bytes image_reference = 3;
53  }
54  ComparisonOptions options = 4;
55
56  // Additional metadata that will be copied verbatim to the DiffResult.
57  repeated Metadata metadata = 5;
58}
59
60message DiffResult {
61  enum Status {
62    UNSPECIFIED = 0;
63    PASSED = 1;  // number_pixels_different <= allowable_number_pixels_different
64    FAILED = 2;
65    // There was no file at the golden location or it was unreadable.
66    MISSING_REFERENCE = 3;
67    FLAKY = 4;  // undefined behavior for single DiffResult
68  }
69
70  message ComparisonStatistics {
71    // Copy of the ComparisonOptions from the DiffRequest.
72    ComparisonOptions comparison_options = 1;
73
74    uint32 number_pixels_compared = 2;
75
76    uint32 number_pixels_identical = 3;
77    uint32 number_pixels_similar = 4;  // within color_allowance
78    // When use_masking in DiffRequest is true, number of pixels that had zero
79    // alpha in the reference image. Otherwise zero.
80    uint32 number_pixels_ignored = 5;
81    uint32 number_pixels_different = 6;
82  }
83
84  Status result_type = 1;
85
86  // See DiffRequest.image_location_golden
87  string image_location_golden = 2;
88
89  // Locations relative to output folder.
90  string image_location_test = 3;
91  string image_location_reference = 4;
92  string image_location_diff = 5;
93
94  ComparisonStatistics comparison_statistics = 6;
95  repeated Metadata metadata = 7;
96
97  // MD5 hash of the difference image.
98  string hash_diff_image = 8;
99  string unique_id = 9;
100}
101
102message Metadata {
103  string key = 1;
104  string value = 2;
105}
106
107message DiffResultList {
108  repeated DiffResult results = 1;
109}
110