From 67809522467a2fdab66282b29e5b019452c5ec8a Mon Sep 17 00:00:00 2001 From: George Wright Date: Thu, 30 Jan 2020 13:22:11 -0800 Subject: [PATCH 1/3] Don't constexpr iphone_xs_times --- shell/common/input_events_unittests.cc | 97 +++++++++++++------------- 1 file changed, 50 insertions(+), 47 deletions(-) diff --git a/shell/common/input_events_unittests.cc b/shell/common/input_events_unittests.cc index 3e08663fff90e..7fc30650febb0 100644 --- a/shell/common/input_events_unittests.cc +++ b/shell/common/input_events_unittests.cc @@ -224,53 +224,56 @@ TEST_F(ShellTest, DelayAtMostOneEventForFasterThanVSyncInputEvents) { TEST_F(ShellTest, HandlesActualIphoneXsInputEvents) { // Actual delivery times measured on iPhone Xs, in the unit of frame_time // (16.67ms for 60Hz). - constexpr double iphone_xs_times[] = {0.15, - 1.0773046874999999, - 2.1738720703124996, - 3.0579052734374996, - 4.0890087890624995, - 5.0952685546875, - 6.1251708984375, - 7.1253076171875, - 8.125927734374999, - 9.37248046875, - 10.133950195312499, - 11.161201171875, - 12.226992187499999, - 13.1443798828125, - 14.440327148437499, - 15.091684570312498, - 16.138681640625, - 17.126469726562497, - 18.1592431640625, - 19.371372070312496, - 20.033774414062496, - 21.021782226562497, - 22.070053710937497, - 23.325541992187496, - 24.119648437499997, - 25.084262695312496, - 26.077866210937497, - 27.036547851562496, - 28.035073242187497, - 29.081411132812498, - 30.066064453124998, - 31.089360351562497, - 32.086142578125, - 33.4618798828125, - 34.14697265624999, - 35.0513525390625, - 36.136025390624994, - 37.1618408203125, - 38.144472656249995, - 39.201123046875, - 40.4339501953125, - 41.1552099609375, - 42.102128906249995, - 43.0426318359375, - 44.070131835937495, - 45.08862304687499, - 46.091469726562494}; + // + // We don't use `constexpr double iphone_xs_times` here because Fuchsia's + // clang doesn't handle it well with lambda capture. + double iphone_xs_times[] = {0.15, + 1.0773046874999999, + 2.1738720703124996, + 3.0579052734374996, + 4.0890087890624995, + 5.0952685546875, + 6.1251708984375, + 7.1253076171875, + 8.125927734374999, + 9.37248046875, + 10.133950195312499, + 11.161201171875, + 12.226992187499999, + 13.1443798828125, + 14.440327148437499, + 15.091684570312498, + 16.138681640625, + 17.126469726562497, + 18.1592431640625, + 19.371372070312496, + 20.033774414062496, + 21.021782226562497, + 22.070053710937497, + 23.325541992187496, + 24.119648437499997, + 25.084262695312496, + 26.077866210937497, + 27.036547851562496, + 28.035073242187497, + 29.081411132812498, + 30.066064453124998, + 31.089360351562497, + 32.086142578125, + 33.4618798828125, + 34.14697265624999, + 35.0513525390625, + 36.136025390624994, + 37.1618408203125, + 38.144472656249995, + 39.201123046875, + 40.4339501953125, + 41.1552099609375, + 42.102128906249995, + 43.0426318359375, + 44.070131835937495, + 45.08862304687499, + 46.091469726562494}; constexpr int n = sizeof(iphone_xs_times) / sizeof(iphone_xs_times[0]); // We don't use `constexpr int frame_time` here because MSVC doesn't handle // it well with lambda capture. From d563ff3563b53be46de175eebf272a0e8e78201d Mon Sep 17 00:00:00 2001 From: George Wright Date: Thu, 30 Jan 2020 14:26:14 -0800 Subject: [PATCH 2/3] const instead --- shell/common/input_events_unittests.cc | 94 +++++++++++++------------- 1 file changed, 47 insertions(+), 47 deletions(-) diff --git a/shell/common/input_events_unittests.cc b/shell/common/input_events_unittests.cc index 7fc30650febb0..575c227509ae0 100644 --- a/shell/common/input_events_unittests.cc +++ b/shell/common/input_events_unittests.cc @@ -227,53 +227,53 @@ TEST_F(ShellTest, HandlesActualIphoneXsInputEvents) { // // We don't use `constexpr double iphone_xs_times` here because Fuchsia's // clang doesn't handle it well with lambda capture. - double iphone_xs_times[] = {0.15, - 1.0773046874999999, - 2.1738720703124996, - 3.0579052734374996, - 4.0890087890624995, - 5.0952685546875, - 6.1251708984375, - 7.1253076171875, - 8.125927734374999, - 9.37248046875, - 10.133950195312499, - 11.161201171875, - 12.226992187499999, - 13.1443798828125, - 14.440327148437499, - 15.091684570312498, - 16.138681640625, - 17.126469726562497, - 18.1592431640625, - 19.371372070312496, - 20.033774414062496, - 21.021782226562497, - 22.070053710937497, - 23.325541992187496, - 24.119648437499997, - 25.084262695312496, - 26.077866210937497, - 27.036547851562496, - 28.035073242187497, - 29.081411132812498, - 30.066064453124998, - 31.089360351562497, - 32.086142578125, - 33.4618798828125, - 34.14697265624999, - 35.0513525390625, - 36.136025390624994, - 37.1618408203125, - 38.144472656249995, - 39.201123046875, - 40.4339501953125, - 41.1552099609375, - 42.102128906249995, - 43.0426318359375, - 44.070131835937495, - 45.08862304687499, - 46.091469726562494}; + const double iphone_xs_times[] = {0.15, + 1.0773046874999999, + 2.1738720703124996, + 3.0579052734374996, + 4.0890087890624995, + 5.0952685546875, + 6.1251708984375, + 7.1253076171875, + 8.125927734374999, + 9.37248046875, + 10.133950195312499, + 11.161201171875, + 12.226992187499999, + 13.1443798828125, + 14.440327148437499, + 15.091684570312498, + 16.138681640625, + 17.126469726562497, + 18.1592431640625, + 19.371372070312496, + 20.033774414062496, + 21.021782226562497, + 22.070053710937497, + 23.325541992187496, + 24.119648437499997, + 25.084262695312496, + 26.077866210937497, + 27.036547851562496, + 28.035073242187497, + 29.081411132812498, + 30.066064453124998, + 31.089360351562497, + 32.086142578125, + 33.4618798828125, + 34.14697265624999, + 35.0513525390625, + 36.136025390624994, + 37.1618408203125, + 38.144472656249995, + 39.201123046875, + 40.4339501953125, + 41.1552099609375, + 42.102128906249995, + 43.0426318359375, + 44.070131835937495, + 45.08862304687499, + 46.091469726562494}; constexpr int n = sizeof(iphone_xs_times) / sizeof(iphone_xs_times[0]); // We don't use `constexpr int frame_time` here because MSVC doesn't handle // it well with lambda capture. From b11d59244ce4d2fef42d9f2cea404adec38c21ff Mon Sep 17 00:00:00 2001 From: George Wright Date: Thu, 30 Jan 2020 15:38:44 -0800 Subject: [PATCH 3/3] use static constexpr --- shell/common/input_events_unittests.cc | 100 ++++++++++++------------- 1 file changed, 48 insertions(+), 52 deletions(-) diff --git a/shell/common/input_events_unittests.cc b/shell/common/input_events_unittests.cc index 575c227509ae0..f7514beabc4b5 100644 --- a/shell/common/input_events_unittests.cc +++ b/shell/common/input_events_unittests.cc @@ -224,56 +224,53 @@ TEST_F(ShellTest, DelayAtMostOneEventForFasterThanVSyncInputEvents) { TEST_F(ShellTest, HandlesActualIphoneXsInputEvents) { // Actual delivery times measured on iPhone Xs, in the unit of frame_time // (16.67ms for 60Hz). - // - // We don't use `constexpr double iphone_xs_times` here because Fuchsia's - // clang doesn't handle it well with lambda capture. - const double iphone_xs_times[] = {0.15, - 1.0773046874999999, - 2.1738720703124996, - 3.0579052734374996, - 4.0890087890624995, - 5.0952685546875, - 6.1251708984375, - 7.1253076171875, - 8.125927734374999, - 9.37248046875, - 10.133950195312499, - 11.161201171875, - 12.226992187499999, - 13.1443798828125, - 14.440327148437499, - 15.091684570312498, - 16.138681640625, - 17.126469726562497, - 18.1592431640625, - 19.371372070312496, - 20.033774414062496, - 21.021782226562497, - 22.070053710937497, - 23.325541992187496, - 24.119648437499997, - 25.084262695312496, - 26.077866210937497, - 27.036547851562496, - 28.035073242187497, - 29.081411132812498, - 30.066064453124998, - 31.089360351562497, - 32.086142578125, - 33.4618798828125, - 34.14697265624999, - 35.0513525390625, - 36.136025390624994, - 37.1618408203125, - 38.144472656249995, - 39.201123046875, - 40.4339501953125, - 41.1552099609375, - 42.102128906249995, - 43.0426318359375, - 44.070131835937495, - 45.08862304687499, - 46.091469726562494}; + static constexpr double iphone_xs_times[] = {0.15, + 1.0773046874999999, + 2.1738720703124996, + 3.0579052734374996, + 4.0890087890624995, + 5.0952685546875, + 6.1251708984375, + 7.1253076171875, + 8.125927734374999, + 9.37248046875, + 10.133950195312499, + 11.161201171875, + 12.226992187499999, + 13.1443798828125, + 14.440327148437499, + 15.091684570312498, + 16.138681640625, + 17.126469726562497, + 18.1592431640625, + 19.371372070312496, + 20.033774414062496, + 21.021782226562497, + 22.070053710937497, + 23.325541992187496, + 24.119648437499997, + 25.084262695312496, + 26.077866210937497, + 27.036547851562496, + 28.035073242187497, + 29.081411132812498, + 30.066064453124998, + 31.089360351562497, + 32.086142578125, + 33.4618798828125, + 34.14697265624999, + 35.0513525390625, + 36.136025390624994, + 37.1618408203125, + 38.144472656249995, + 39.201123046875, + 40.4339501953125, + 41.1552099609375, + 42.102128906249995, + 43.0426318359375, + 44.070131835937495, + 45.08862304687499, + 46.091469726562494}; constexpr int n = sizeof(iphone_xs_times) / sizeof(iphone_xs_times[0]); // We don't use `constexpr int frame_time` here because MSVC doesn't handle // it well with lambda capture. @@ -283,8 +280,7 @@ TEST_F(ShellTest, HandlesActualIphoneXsInputEvents) { // TestSimulatedInputEvents. UnitlessTime base_latency = static_cast(base_latency_f * frame_time); - Generator iphone_xs_generator = [frame_time, iphone_xs_times, - base_latency](int i) { + Generator iphone_xs_generator = [frame_time, base_latency](int i) { return base_latency + static_cast(iphone_xs_times[i] * frame_time); };