Flutter Engine
flutter_runner_product_configuration_unittests.cc
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include <gtest/gtest.h>
6 
7 #include "flutter/fml/time/time_delta.h"
8 #include "flutter/shell/platform/fuchsia/flutter/flutter_runner_product_configuration.h"
9 
10 using namespace flutter_runner;
11 
12 namespace flutter_runner_test {
13 
14 class FlutterRunnerProductConfigurationTest : public testing::Test {};
15 
17  const std::string json_string = "{ \"vsync_offset_in_us\" : 9000 } ";
18  const fml::TimeDelta expected_offset = fml::TimeDelta::FromMicroseconds(9000);
19 
20  FlutterRunnerProductConfiguration product_config =
22  EXPECT_EQ(product_config.get_vsync_offset(), expected_offset);
23 }
24 
26  const std::string json_string = "{ \"invalid json string\" }}} ";
27  const fml::TimeDelta expected_offset = fml::TimeDelta::FromMicroseconds(0);
28 
29  FlutterRunnerProductConfiguration product_config =
31  EXPECT_EQ(product_config.get_vsync_offset(), expected_offset);
32 }
33 
35  const std::string json_string = "";
36  const fml::TimeDelta expected_offset = fml::TimeDelta::FromMicroseconds(0);
37 
38  FlutterRunnerProductConfiguration product_config =
40  EXPECT_EQ(product_config.get_vsync_offset(), expected_offset);
41 }
42 
44  const std::string json_string = "{ \"vsync_offset_in_us\" : } ";
45  const fml::TimeDelta expected_offset = fml::TimeDelta::FromMicroseconds(0);
46 
47  FlutterRunnerProductConfiguration product_config =
49  EXPECT_EQ(product_config.get_vsync_offset(), expected_offset);
50 }
51 
53  const std::string json_string = "{ \"vsync_offset_in_us\" : -15410 } ";
54  const fml::TimeDelta expected_offset =
56 
57  FlutterRunnerProductConfiguration product_config =
59  EXPECT_EQ(product_config.get_vsync_offset(), expected_offset);
60 }
61 
63  const std::string json_string = "{ \"vsync_offset_in_us\" : 3.14159 } ";
64  const fml::TimeDelta expected_offset = fml::TimeDelta::FromMicroseconds(0);
65 
66  FlutterRunnerProductConfiguration product_config =
68  EXPECT_EQ(product_config.get_vsync_offset(), expected_offset);
69 }
70 
72  const std::string json_string = "{ \"max_frames_in_flight\" : 5 } ";
73  const uint64_t expected_max_frames_in_flight = 5;
74 
75  FlutterRunnerProductConfiguration product_config =
77  EXPECT_EQ(product_config.get_max_frames_in_flight(),
78  expected_max_frames_in_flight);
79 }
80 
81 TEST_F(FlutterRunnerProductConfigurationTest, MissingMaxFramesInFlight) {
82  const std::string json_string = "{ \"max_frames_in_flight\" : } ";
83  const uint64_t minimum_reasonable_max_frames_in_flight = 1;
84 
85  FlutterRunnerProductConfiguration product_config =
87  EXPECT_GE(product_config.get_max_frames_in_flight(),
88  minimum_reasonable_max_frames_in_flight);
89 }
90 
92  const std::string json_string = "{ \"intercept_all_input\" : true } ";
93  const uint64_t expected_intercept_all_input = true;
94 
95  FlutterRunnerProductConfiguration product_config =
97 
98  EXPECT_EQ(expected_intercept_all_input,
99  product_config.get_intercept_all_input());
100 }
101 
102 TEST_F(FlutterRunnerProductConfigurationTest, MissingInterceptAllInput) {
103  const std::string json_string = "{ \"intercept_all_input\" : } ";
104  const uint64_t expected_intercept_all_input = false;
105 
106  FlutterRunnerProductConfiguration product_config =
108 
109  EXPECT_EQ(expected_intercept_all_input,
110  product_config.get_intercept_all_input());
111 }
112 
113 } // namespace flutter_runner_test
static constexpr TimeDelta FromMicroseconds(int64_t micros)
Definition: time_delta.h:43
TEST_F(FlutterRunnerProductConfigurationTest, MissingInterceptAllInput)