未验证 提交 87723655 编写于 作者: F Felipe Archondo 提交者: GitHub

[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
上级 2e3f1326
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
// found in the LICENSE file. // found in the LICENSE file.
#include "flutter_runner_product_configuration.h" #include "flutter_runner_product_configuration.h"
#include <zircon/assert.h>
#include "rapidjson/document.h" #include "rapidjson/document.h"
...@@ -17,15 +18,26 @@ FlutterRunnerProductConfiguration::FlutterRunnerProductConfiguration( ...@@ -17,15 +18,26 @@ FlutterRunnerProductConfiguration::FlutterRunnerProductConfiguration(
return; return;
// Parse out all values we're expecting. // Parse out all values we're expecting.
if (auto& val = document["vsync_offset_in_us"]; val.IsInt()) { if (document.HasMember("vsync_offset_in_us")) {
vsync_offset_ = fml::TimeDelta::FromMicroseconds(val.GetInt()); auto& val = document["vsync_offset_in_us"];
if (val.IsInt())
vsync_offset_ = fml::TimeDelta::FromMicroseconds(val.GetInt());
} }
if (auto& val = document["max_frames_in_flight"]; val.IsInt()) { if (document.HasMember("max_frames_in_flight")) {
max_frames_in_flight_ = val.GetInt(); auto& val = document["max_frames_in_flight"];
if (val.IsInt())
max_frames_in_flight_ = val.GetInt();
}
if (document.HasMember("intercept_all_input")) {
auto& val = document["intercept_all_input"];
if (val.IsBool())
intercept_all_input_ = val.GetBool();
} }
#if defined(LEGACY_FUCHSIA_EMBEDDER) #if defined(LEGACY_FUCHSIA_EMBEDDER)
if (auto& val = document["use_legacy_renderer"]; val.IsBool()) { if (document.HasMember("use_legacy_renderer")) {
use_legacy_renderer_ = val.GetBool(); auto& val = document["use_legacy_renderer"];
if (val.IsBool())
use_legacy_renderer_ = val.GetBool();
} }
#endif #endif
} }
......
...@@ -16,6 +16,7 @@ class FlutterRunnerProductConfiguration { ...@@ -16,6 +16,7 @@ class FlutterRunnerProductConfiguration {
fml::TimeDelta get_vsync_offset() { return vsync_offset_; } fml::TimeDelta get_vsync_offset() { return vsync_offset_; }
uint64_t get_max_frames_in_flight() { return max_frames_in_flight_; } uint64_t get_max_frames_in_flight() { return max_frames_in_flight_; }
bool get_intercept_all_input() { return intercept_all_input_; }
#if defined(LEGACY_FUCHSIA_EMBEDDER) #if defined(LEGACY_FUCHSIA_EMBEDDER)
bool use_legacy_renderer() { return use_legacy_renderer_; } bool use_legacy_renderer() { return use_legacy_renderer_; }
#endif #endif
...@@ -23,6 +24,7 @@ class FlutterRunnerProductConfiguration { ...@@ -23,6 +24,7 @@ class FlutterRunnerProductConfiguration {
private: private:
fml::TimeDelta vsync_offset_ = fml::TimeDelta::Zero(); fml::TimeDelta vsync_offset_ = fml::TimeDelta::Zero();
uint64_t max_frames_in_flight_ = 3; uint64_t max_frames_in_flight_ = 3;
bool intercept_all_input_ = false;
#if defined(LEGACY_FUCHSIA_EMBEDDER) #if defined(LEGACY_FUCHSIA_EMBEDDER)
bool use_legacy_renderer_ = true; bool use_legacy_renderer_ = true;
#endif #endif
......
...@@ -88,4 +88,26 @@ TEST_F(FlutterRunnerProductConfigurationTest, MissingMaxFramesInFlight) { ...@@ -88,4 +88,26 @@ TEST_F(FlutterRunnerProductConfigurationTest, MissingMaxFramesInFlight) {
minimum_reasonable_max_frames_in_flight); minimum_reasonable_max_frames_in_flight);
} }
TEST_F(FlutterRunnerProductConfigurationTest, ValidInterceptAllInput) {
const std::string json_string = "{ \"intercept_all_input\" : true } ";
const uint64_t expected_intercept_all_input = true;
FlutterRunnerProductConfiguration product_config =
FlutterRunnerProductConfiguration(json_string);
EXPECT_EQ(expected_intercept_all_input,
product_config.get_intercept_all_input());
}
TEST_F(FlutterRunnerProductConfigurationTest, MissingInterceptAllInput) {
const std::string json_string = "{ \"intercept_all_input\" : } ";
const uint64_t expected_intercept_all_input = false;
FlutterRunnerProductConfiguration product_config =
FlutterRunnerProductConfiguration(json_string);
EXPECT_EQ(expected_intercept_all_input,
product_config.get_intercept_all_input());
}
} // namespace flutter_runner_test } // namespace flutter_runner_test
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册