Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(781)

Side by Side Diff: components/zoom/page_zoom_unittests.cc

Issue 2019423005: Move //components/ui/zoom to top-level under //components (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/zoom/page_zoom_constants.cc ('k') | components/zoom/test/DEPS » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/ui/zoom/page_zoom.h" 5 #include "components/zoom/page_zoom.h"
6 #include "content/public/common/page_zoom.h" 6 #include "content/public/common/page_zoom.h"
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 8
9 TEST(PageTestZoom, PresetZoomFactors) { 9 TEST(PageTestZoom, PresetZoomFactors) {
10 // Fetch a vector of preset zoom factors, including a custom value that we 10 // Fetch a vector of preset zoom factors, including a custom value that we
11 // already know is not going to be in the list. 11 // already know is not going to be in the list.
12 double custom_value = 1.05; // 105% 12 double custom_value = 1.05; // 105%
13 std::vector<double> factors = 13 std::vector<double> factors = zoom::PageZoom::PresetZoomFactors(custom_value);
14 ui_zoom::PageZoom::PresetZoomFactors(custom_value);
15 14
16 // Expect at least 10 zoom factors. 15 // Expect at least 10 zoom factors.
17 EXPECT_GE(factors.size(), 10U); 16 EXPECT_GE(factors.size(), 10U);
18 17
19 // Expect the first and last items to match the minimum and maximum values. 18 // Expect the first and last items to match the minimum and maximum values.
20 EXPECT_DOUBLE_EQ(factors.front(), content::kMinimumZoomFactor); 19 EXPECT_DOUBLE_EQ(factors.front(), content::kMinimumZoomFactor);
21 EXPECT_DOUBLE_EQ(factors.back(), content::kMaximumZoomFactor); 20 EXPECT_DOUBLE_EQ(factors.back(), content::kMaximumZoomFactor);
22 21
23 // Iterate through the vector, with the following checks: 22 // Iterate through the vector, with the following checks:
24 // 1. The values are in sorted order. 23 // 1. The values are in sorted order.
(...skipping 15 matching lines...) Expand all
40 } 39 }
41 40
42 EXPECT_TRUE(found_custom_value); 41 EXPECT_TRUE(found_custom_value);
43 EXPECT_TRUE(found_100_percent); 42 EXPECT_TRUE(found_100_percent);
44 } 43 }
45 44
46 TEST(PageTestZoom, PresetZoomLevels) { 45 TEST(PageTestZoom, PresetZoomLevels) {
47 // Fetch a vector of preset zoom levels, including a custom value that we 46 // Fetch a vector of preset zoom levels, including a custom value that we
48 // already know is not going to be in the list. 47 // already know is not going to be in the list.
49 double custom_value = 0.1; 48 double custom_value = 0.1;
50 std::vector<double> levels = 49 std::vector<double> levels = zoom::PageZoom::PresetZoomLevels(custom_value);
51 ui_zoom::PageZoom::PresetZoomLevels(custom_value);
52 50
53 // Expect at least 10 zoom levels. 51 // Expect at least 10 zoom levels.
54 EXPECT_GE(levels.size(), 10U); 52 EXPECT_GE(levels.size(), 10U);
55 53
56 // Iterate through the vector, with the following checks: 54 // Iterate through the vector, with the following checks:
57 // 1. The values are in sorted order. 55 // 1. The values are in sorted order.
58 // 2. The custom value is exists. 56 // 2. The custom value is exists.
59 // 3. The 100% value exists. 57 // 3. The 100% value exists.
60 bool found_custom_value = false; 58 bool found_custom_value = false;
61 bool found_100_percent = false; 59 bool found_100_percent = false;
62 double last_value = -99; 60 double last_value = -99;
63 61
64 std::vector<double>::const_iterator i; 62 std::vector<double>::const_iterator i;
65 for (i = levels.begin(); i != levels.end(); ++i) { 63 for (i = levels.begin(); i != levels.end(); ++i) {
66 double level = *i; 64 double level = *i;
67 EXPECT_GT(level, last_value); 65 EXPECT_GT(level, last_value);
68 if (content::ZoomValuesEqual(level, custom_value)) 66 if (content::ZoomValuesEqual(level, custom_value))
69 found_custom_value = true; 67 found_custom_value = true;
70 if (content::ZoomValuesEqual(level, 0)) 68 if (content::ZoomValuesEqual(level, 0))
71 found_100_percent = true; 69 found_100_percent = true;
72 last_value = level; 70 last_value = level;
73 } 71 }
74 72
75 EXPECT_TRUE(found_custom_value); 73 EXPECT_TRUE(found_custom_value);
76 EXPECT_TRUE(found_100_percent); 74 EXPECT_TRUE(found_100_percent);
77 } 75 }
78 76
79 TEST(PageTestZoom, InvalidCustomFactor) { 77 TEST(PageTestZoom, InvalidCustomFactor) {
80 double too_low = 0.01; 78 double too_low = 0.01;
81 std::vector<double> factors = ui_zoom::PageZoom::PresetZoomFactors(too_low); 79 std::vector<double> factors = zoom::PageZoom::PresetZoomFactors(too_low);
82 EXPECT_FALSE(content::ZoomValuesEqual(factors.front(), too_low)); 80 EXPECT_FALSE(content::ZoomValuesEqual(factors.front(), too_low));
83 81
84 double too_high = 99.0; 82 double too_high = 99.0;
85 factors = ui_zoom::PageZoom::PresetZoomFactors(too_high); 83 factors = zoom::PageZoom::PresetZoomFactors(too_high);
86 EXPECT_FALSE(content::ZoomValuesEqual(factors.back(), too_high)); 84 EXPECT_FALSE(content::ZoomValuesEqual(factors.back(), too_high));
87 } 85 }
88 86
89 TEST(PageTestZoom, InvalidCustomLevel) { 87 TEST(PageTestZoom, InvalidCustomLevel) {
90 double too_low = -99.0; 88 double too_low = -99.0;
91 std::vector<double> levels = ui_zoom::PageZoom::PresetZoomLevels(too_low); 89 std::vector<double> levels = zoom::PageZoom::PresetZoomLevels(too_low);
92 EXPECT_FALSE(content::ZoomValuesEqual(levels.front(), too_low)); 90 EXPECT_FALSE(content::ZoomValuesEqual(levels.front(), too_low));
93 91
94 double too_high = 99.0; 92 double too_high = 99.0;
95 levels = ui_zoom::PageZoom::PresetZoomLevels(too_high); 93 levels = zoom::PageZoom::PresetZoomLevels(too_high);
96 EXPECT_FALSE(content::ZoomValuesEqual(levels.back(), too_high)); 94 EXPECT_FALSE(content::ZoomValuesEqual(levels.back(), too_high));
97 } 95 }
98
OLDNEW
« no previous file with comments | « components/zoom/page_zoom_constants.cc ('k') | components/zoom/test/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698