Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 8772365

Browse files
authored
[fuchsia] add intercept_all_input flag support (#21821)
[fuchsia] add intercept_all_input flag support This change also fixes an issue where FlutterRunnerProductConfiguration crashes when a field is missing, when building with --unopt. Test: Added unit tests Bug: fxb/61466, fxb/61942
1 parent 2e3f132 commit 8772365

3 files changed

Lines changed: 42 additions & 6 deletions

File tree

shell/platform/fuchsia/flutter/flutter_runner_product_configuration.cc

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// found in the LICENSE file.
44

55
#include "flutter_runner_product_configuration.h"
6+
#include <zircon/assert.h>
67

78
#include "rapidjson/document.h"
89

@@ -17,15 +18,26 @@ FlutterRunnerProductConfiguration::FlutterRunnerProductConfiguration(
1718
return;
1819

1920
// Parse out all values we're expecting.
20-
if (auto& val = document["vsync_offset_in_us"]; val.IsInt()) {
21-
vsync_offset_ = fml::TimeDelta::FromMicroseconds(val.GetInt());
21+
if (document.HasMember("vsync_offset_in_us")) {
22+
auto& val = document["vsync_offset_in_us"];
23+
if (val.IsInt())
24+
vsync_offset_ = fml::TimeDelta::FromMicroseconds(val.GetInt());
2225
}
23-
if (auto& val = document["max_frames_in_flight"]; val.IsInt()) {
24-
max_frames_in_flight_ = val.GetInt();
26+
if (document.HasMember("max_frames_in_flight")) {
27+
auto& val = document["max_frames_in_flight"];
28+
if (val.IsInt())
29+
max_frames_in_flight_ = val.GetInt();
30+
}
31+
if (document.HasMember("intercept_all_input")) {
32+
auto& val = document["intercept_all_input"];
33+
if (val.IsBool())
34+
intercept_all_input_ = val.GetBool();
2535
}
2636
#if defined(LEGACY_FUCHSIA_EMBEDDER)
27-
if (auto& val = document["use_legacy_renderer"]; val.IsBool()) {
28-
use_legacy_renderer_ = val.GetBool();
37+
if (document.HasMember("use_legacy_renderer")) {
38+
auto& val = document["use_legacy_renderer"];
39+
if (val.IsBool())
40+
use_legacy_renderer_ = val.GetBool();
2941
}
3042
#endif
3143
}

shell/platform/fuchsia/flutter/flutter_runner_product_configuration.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,15 @@ class FlutterRunnerProductConfiguration {
1616

1717
fml::TimeDelta get_vsync_offset() { return vsync_offset_; }
1818
uint64_t get_max_frames_in_flight() { return max_frames_in_flight_; }
19+
bool get_intercept_all_input() { return intercept_all_input_; }
1920
#if defined(LEGACY_FUCHSIA_EMBEDDER)
2021
bool use_legacy_renderer() { return use_legacy_renderer_; }
2122
#endif
2223

2324
private:
2425
fml::TimeDelta vsync_offset_ = fml::TimeDelta::Zero();
2526
uint64_t max_frames_in_flight_ = 3;
27+
bool intercept_all_input_ = false;
2628
#if defined(LEGACY_FUCHSIA_EMBEDDER)
2729
bool use_legacy_renderer_ = true;
2830
#endif

shell/platform/fuchsia/flutter/tests/flutter_runner_product_configuration_unittests.cc

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,26 @@ TEST_F(FlutterRunnerProductConfigurationTest, MissingMaxFramesInFlight) {
8888
minimum_reasonable_max_frames_in_flight);
8989
}
9090

91+
TEST_F(FlutterRunnerProductConfigurationTest, ValidInterceptAllInput) {
92+
const std::string json_string = "{ \"intercept_all_input\" : true } ";
93+
const uint64_t expected_intercept_all_input = true;
94+
95+
FlutterRunnerProductConfiguration product_config =
96+
FlutterRunnerProductConfiguration(json_string);
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 =
107+
FlutterRunnerProductConfiguration(json_string);
108+
109+
EXPECT_EQ(expected_intercept_all_input,
110+
product_config.get_intercept_all_input());
111+
}
112+
91113
} // namespace flutter_runner_test

0 commit comments

Comments
 (0)