Skip to content

Commit

Permalink
Add check for the precision of display zoom value
Browse files Browse the repository at this point in the history
Display preferences for chrome OS stores the display zoom value only
upto a precision of 2 decimal point.

This patch adds a check of precision to ensure that in the future if
any changes are made to the way display zoom values are generated then
those changes keep in mind this precision that is used by display prefs.

Bug: 823922
Change-Id: I8370415041bcaeac55c4afef9a4e4125979559b4
Component: Display Util Test
Reviewed-on: https://chromium-review.googlesource.com/974264
Reviewed-by: Mitsuru Oshima <oshima@chromium.org>
Commit-Queue: Malay Keshav <malaykeshav@chromium.org>
Cr-Commit-Position: refs/heads/master@{#544897}
  • Loading branch information
Malay Keshav authored and Commit Bot committed Mar 21, 2018
1 parent b5891ad commit 0f9bdf4
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion ui/display/manager/chromeos/display_utils_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,18 @@ TEST_F(DisplayUtilTest, DisplayZooms) {
ManagedDisplayMode mode(gfx::Size(size, size), 60, false, true, 1.f, 1.f);
const std::vector<double> zoom_values = GetDisplayZoomFactors(mode);
EXPECT_EQ(zoom_values.size(), kNumOfZoomFactors);
for (std::size_t j = 0; j < kNumOfZoomFactors; j++)
for (std::size_t j = 0; j < kNumOfZoomFactors; j++) {
EXPECT_NEAR(zoom_values[j], pair.second[j], 0.001);

// Display pref stores the zoom value only upto 2 decimal places. This
// check ensures that the expected precision is only upto 2 decimal
// points. Before changing this line please ensure that you have updated
// chromeos/display/display_prefs.cc
int percentage_value = std::round(zoom_values[j] * 100.f);
float fractional_value = static_cast<float>(percentage_value) / 100.f;
EXPECT_NEAR(zoom_values[j], fractional_value, 0.0001f);
}

const int effective_minimum_width_possible = size / zoom_values.back();
const int effective_maximum_width_possible = size * zoom_values.front();

Expand Down

0 comments on commit 0f9bdf4

Please sign in to comment.