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

Side by Side Diff: chrome/browser/chrome_page_zoom_unittest.cc

Issue 8528011: Page zoom improvements (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: One last(?) tweak. Created 9 years, 1 month 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 | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/chrome_page_zoom.h"
6 #include "content/public/common/page_zoom.h"
7
jam 2011/11/22 01:22:43 nit: not needed
8 #include "testing/gtest/include/gtest/gtest.h"
9
10 TEST(ChromePageZoomTest, PresetZoomFactors) {
11 // Fetch a vector of preset zoom factors, including a custom value that we
12 // already know is not going to be in the list.
13 double custom_value = 1.05; // 105%
14 std::vector<double> factors =
15 chrome_page_zoom::PresetZoomFactors(custom_value);
16
17 // Expect at least 10 zoom factors.
18 EXPECT_GE(factors.size(), 10U);
19
20 // Expect the first and last items to match the minimum and maximum values.
21 EXPECT_DOUBLE_EQ(factors.front(), content::kMinimumZoomFactor);
22 EXPECT_DOUBLE_EQ(factors.back(), content::kMaximumZoomFactor);
23
24 // Iterate through the vector, with the following checks:
25 // 1. The values are in sorted order.
26 // 2. The custom value is exists.
27 // 3. The 100% value exists.
28 bool found_custom_value = false;
29 bool found_100_percent = false;
30 double last_value = 0;
31
32 std::vector<double>::const_iterator i;
33 for (i = factors.begin(); i != factors.end(); ++i) {
34 double factor = *i;
35 EXPECT_GT(factor, last_value);
36 if (content::ZoomValuesEqual(factor, custom_value))
37 found_custom_value = true;
38 if (content::ZoomValuesEqual(factor, 1.0))
39 found_100_percent = true;
40 last_value = factor;
41 }
42
43 EXPECT_TRUE(found_custom_value);
44 EXPECT_TRUE(found_100_percent);
45 }
46
47 TEST(ChromePageZoomTest, PresetZoomLevels) {
48 // Fetch a vector of preset zoom levels, including a custom value that we
49 // already know is not going to be in the list.
50 double custom_value = 0.1;
51 std::vector<double> levels = chrome_page_zoom::PresetZoomLevels(custom_value);
52
53 // Expect at least 10 zoom levels.
54 EXPECT_GE(levels.size(), 10U);
55
56 // Iterate through the vector, with the following checks:
57 // 1. The values are in sorted order.
58 // 2. The custom value is exists.
59 // 3. The 100% value exists.
60 bool found_custom_value = false;
61 bool found_100_percent = false;
62 double last_value = -99;
63
64 std::vector<double>::const_iterator i;
65 for (i = levels.begin(); i != levels.end(); ++i) {
66 double level = *i;
67 EXPECT_GT(level, last_value);
68 if (content::ZoomValuesEqual(level, custom_value))
69 found_custom_value = true;
70 if (content::ZoomValuesEqual(level, 0))
71 found_100_percent = true;
72 last_value = level;
73 }
74
75 EXPECT_TRUE(found_custom_value);
76 EXPECT_TRUE(found_100_percent);
77 }
78
79 TEST(ChromePageZoomTest, InvalidCustomFactor) {
80 double too_low = 0.01;
81 std::vector<double> factors = chrome_page_zoom::PresetZoomFactors(too_low);
82 EXPECT_FALSE(content::ZoomValuesEqual(factors.front(), too_low));
83
84 double too_high = 99.0;
85 factors = chrome_page_zoom::PresetZoomFactors(too_high);
86 EXPECT_FALSE(content::ZoomValuesEqual(factors.back(), too_high));
87 }
88
89 TEST(ChromePageZoomTest, InvalidCustomLevel) {
90 double too_low = -99.0;
91 std::vector<double> levels = chrome_page_zoom::PresetZoomLevels(too_low);
92 EXPECT_FALSE(content::ZoomValuesEqual(levels.front(), too_low));
93
94 double too_high = 99.0;
95 levels = chrome_page_zoom::PresetZoomLevels(too_high);
96 EXPECT_FALSE(content::ZoomValuesEqual(levels.back(), too_high));
97 }
98
OLDNEW
« no previous file with comments | « chrome/browser/chrome_page_zoom.cc ('k') | chrome/browser/resources/options/advanced_options.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698