This source file includes following definitions.
- TEST
- TEST
- TEST
- TEST
#include "chrome/browser/chrome_page_zoom.h"
#include "content/public/common/page_zoom.h"
#include "testing/gtest/include/gtest/gtest.h"
TEST(ChromePageZoomTest, PresetZoomFactors) {
double custom_value = 1.05;
std::vector<double> factors =
chrome_page_zoom::PresetZoomFactors(custom_value);
EXPECT_GE(factors.size(), 10U);
EXPECT_DOUBLE_EQ(factors.front(), content::kMinimumZoomFactor);
EXPECT_DOUBLE_EQ(factors.back(), content::kMaximumZoomFactor);
bool found_custom_value = false;
bool found_100_percent = false;
double last_value = 0;
std::vector<double>::const_iterator i;
for (i = factors.begin(); i != factors.end(); ++i) {
double factor = *i;
EXPECT_GT(factor, last_value);
if (content::ZoomValuesEqual(factor, custom_value))
found_custom_value = true;
if (content::ZoomValuesEqual(factor, 1.0))
found_100_percent = true;
last_value = factor;
}
EXPECT_TRUE(found_custom_value);
EXPECT_TRUE(found_100_percent);
}
TEST(ChromePageZoomTest, PresetZoomLevels) {
double custom_value = 0.1;
std::vector<double> levels = chrome_page_zoom::PresetZoomLevels(custom_value);
EXPECT_GE(levels.size(), 10U);
bool found_custom_value = false;
bool found_100_percent = false;
double last_value = -99;
std::vector<double>::const_iterator i;
for (i = levels.begin(); i != levels.end(); ++i) {
double level = *i;
EXPECT_GT(level, last_value);
if (content::ZoomValuesEqual(level, custom_value))
found_custom_value = true;
if (content::ZoomValuesEqual(level, 0))
found_100_percent = true;
last_value = level;
}
EXPECT_TRUE(found_custom_value);
EXPECT_TRUE(found_100_percent);
}
TEST(ChromePageZoomTest, InvalidCustomFactor) {
double too_low = 0.01;
std::vector<double> factors = chrome_page_zoom::PresetZoomFactors(too_low);
EXPECT_FALSE(content::ZoomValuesEqual(factors.front(), too_low));
double too_high = 99.0;
factors = chrome_page_zoom::PresetZoomFactors(too_high);
EXPECT_FALSE(content::ZoomValuesEqual(factors.back(), too_high));
}
TEST(ChromePageZoomTest, InvalidCustomLevel) {
double too_low = -99.0;
std::vector<double> levels = chrome_page_zoom::PresetZoomLevels(too_low);
EXPECT_FALSE(content::ZoomValuesEqual(levels.front(), too_low));
double too_high = 99.0;
levels = chrome_page_zoom::PresetZoomLevels(too_high);
EXPECT_FALSE(content::ZoomValuesEqual(levels.back(), too_high));
}