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

Unified Diff: ui/base/layout_unittest.cc

Issue 23011044: Added 125% DPI option to ui::ScaleFactors. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/base/layout.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/layout_unittest.cc
diff --git a/ui/base/layout_unittest.cc b/ui/base/layout_unittest.cc
index a230d5ae666916ea0928a5f10924cabb9fbcfd48..8a741821e8c4b9edbfc264749cff3e74b988d770 100644
--- a/ui/base/layout_unittest.cc
+++ b/ui/base/layout_unittest.cc
@@ -1,101 +1,103 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "ui/base/layout.h"
-
-#include "testing/gtest/include/gtest/gtest.h"
-
-#if defined(OS_CHROMEOS)
-#include "base/command_line.h"
-#include "ui/base/ui_base_switches.h"
-#endif
-
-namespace ui {
-
-TEST(LayoutTest, GetScaleFactorScale) {
- EXPECT_FLOAT_EQ(1.0f, GetScaleFactorScale(SCALE_FACTOR_100P));
- EXPECT_FLOAT_EQ(1.33f, GetScaleFactorScale(SCALE_FACTOR_133P));
- EXPECT_FLOAT_EQ(1.4f, GetScaleFactorScale(SCALE_FACTOR_140P));
- EXPECT_FLOAT_EQ(1.5f, GetScaleFactorScale(SCALE_FACTOR_150P));
- EXPECT_FLOAT_EQ(1.8f, GetScaleFactorScale(SCALE_FACTOR_180P));
- EXPECT_FLOAT_EQ(2.0f, GetScaleFactorScale(SCALE_FACTOR_200P));
-}
-
-TEST(LayoutTest, GetScaleFactorFromScalePartlySupported) {
- std::vector<ScaleFactor> supported_factors;
- supported_factors.push_back(SCALE_FACTOR_100P);
- supported_factors.push_back(SCALE_FACTOR_180P);
- test::ScopedSetSupportedScaleFactors scoped_supported(supported_factors);
- EXPECT_EQ(SCALE_FACTOR_100P, GetScaleFactorFromScale(0.1f));
- EXPECT_EQ(SCALE_FACTOR_100P, GetScaleFactorFromScale(0.9f));
- EXPECT_EQ(SCALE_FACTOR_100P, GetScaleFactorFromScale(1.0f));
- EXPECT_EQ(SCALE_FACTOR_100P, GetScaleFactorFromScale(1.39f));
- EXPECT_EQ(SCALE_FACTOR_180P, GetScaleFactorFromScale(1.41f));
- EXPECT_EQ(SCALE_FACTOR_180P, GetScaleFactorFromScale(1.8f));
- EXPECT_EQ(SCALE_FACTOR_180P, GetScaleFactorFromScale(2.0f));
- EXPECT_EQ(SCALE_FACTOR_180P, GetScaleFactorFromScale(999.0f));
-}
-
-TEST(LayoutTest, GetScaleFactorFromScaleAllSupported) {
- std::vector<ScaleFactor> supported_factors;
- for (int factor = SCALE_FACTOR_100P; factor < NUM_SCALE_FACTORS; ++factor) {
- supported_factors.push_back(static_cast<ScaleFactor>(factor));
- }
- test::ScopedSetSupportedScaleFactors scoped_supported(supported_factors);
-
- EXPECT_EQ(SCALE_FACTOR_100P, GetScaleFactorFromScale(0.1f));
- EXPECT_EQ(SCALE_FACTOR_100P, GetScaleFactorFromScale(0.9f));
- EXPECT_EQ(SCALE_FACTOR_100P, GetScaleFactorFromScale(1.0f));
- EXPECT_EQ(SCALE_FACTOR_133P, GetScaleFactorFromScale(1.19f));
- EXPECT_EQ(SCALE_FACTOR_133P, GetScaleFactorFromScale(1.21f));
- EXPECT_EQ(SCALE_FACTOR_133P, GetScaleFactorFromScale(1.3f));
- EXPECT_EQ(SCALE_FACTOR_140P, GetScaleFactorFromScale(1.4f));
- EXPECT_EQ(SCALE_FACTOR_150P, GetScaleFactorFromScale(1.59f));
- EXPECT_EQ(SCALE_FACTOR_150P, GetScaleFactorFromScale(1.61f));
- EXPECT_EQ(SCALE_FACTOR_180P, GetScaleFactorFromScale(1.7f));
- EXPECT_EQ(SCALE_FACTOR_180P, GetScaleFactorFromScale(1.89f));
- EXPECT_EQ(SCALE_FACTOR_200P, GetScaleFactorFromScale(1.91f));
- EXPECT_EQ(SCALE_FACTOR_200P, GetScaleFactorFromScale(2.0f));
- EXPECT_EQ(SCALE_FACTOR_200P, GetScaleFactorFromScale(2.1f));
- EXPECT_EQ(SCALE_FACTOR_200P, GetScaleFactorFromScale(999.0f));
-}
-
-TEST(LayoutTest, GetMaxScaleFactor) {
-#if defined(OS_CHROMEOS)
- // On Chrome OS, the maximum scale factor is based on
- // the available resource pack. In testing environment,
- // we always have 200P.
- EXPECT_EQ(SCALE_FACTOR_200P, GetMaxScaleFactor());
-#else
- {
- ScaleFactor scale_factors[] = { SCALE_FACTOR_100P };
- std::vector<ScaleFactor> supported_factors(
- scale_factors, scale_factors + arraysize(scale_factors));
- test::ScopedSetSupportedScaleFactors scoped_supported(supported_factors);
- EXPECT_EQ(SCALE_FACTOR_100P, GetMaxScaleFactor());
- }
-
- {
- ScaleFactor scale_factors[] = { SCALE_FACTOR_100P,
- SCALE_FACTOR_140P };
- std::vector<ScaleFactor> supported_factors(
- scale_factors, scale_factors + arraysize(scale_factors));
- test::ScopedSetSupportedScaleFactors scoped_supported(supported_factors);
- EXPECT_EQ(SCALE_FACTOR_140P, GetMaxScaleFactor());
- }
-
- {
- ScaleFactor scale_factors[] = { SCALE_FACTOR_200P,
- SCALE_FACTOR_180P,
- SCALE_FACTOR_140P,
- SCALE_FACTOR_100P };
- std::vector<ScaleFactor> supported_factors(
- scale_factors, scale_factors + arraysize(scale_factors));
- test::ScopedSetSupportedScaleFactors scoped_supported(supported_factors);
- EXPECT_EQ(SCALE_FACTOR_200P, GetMaxScaleFactor());
- }
-#endif
-}
-
-} // namespace ui
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/base/layout.h"
+
+#include "testing/gtest/include/gtest/gtest.h"
+
+#if defined(OS_CHROMEOS)
+#include "base/command_line.h"
+#include "ui/base/ui_base_switches.h"
+#endif
+
+namespace ui {
+
+TEST(LayoutTest, GetScaleFactorScale) {
+ EXPECT_FLOAT_EQ(1.0f, GetScaleFactorScale(SCALE_FACTOR_100P));
+ EXPECT_FLOAT_EQ(1.25f, GetScaleFactorScale(SCALE_FACTOR_125P));
+ EXPECT_FLOAT_EQ(1.33f, GetScaleFactorScale(SCALE_FACTOR_133P));
+ EXPECT_FLOAT_EQ(1.4f, GetScaleFactorScale(SCALE_FACTOR_140P));
+ EXPECT_FLOAT_EQ(1.5f, GetScaleFactorScale(SCALE_FACTOR_150P));
+ EXPECT_FLOAT_EQ(1.8f, GetScaleFactorScale(SCALE_FACTOR_180P));
+ EXPECT_FLOAT_EQ(2.0f, GetScaleFactorScale(SCALE_FACTOR_200P));
+}
+
+TEST(LayoutTest, GetScaleFactorFromScalePartlySupported) {
+ std::vector<ScaleFactor> supported_factors;
+ supported_factors.push_back(SCALE_FACTOR_100P);
+ supported_factors.push_back(SCALE_FACTOR_180P);
+ test::ScopedSetSupportedScaleFactors scoped_supported(supported_factors);
+ EXPECT_EQ(SCALE_FACTOR_100P, GetScaleFactorFromScale(0.1f));
+ EXPECT_EQ(SCALE_FACTOR_100P, GetScaleFactorFromScale(0.9f));
+ EXPECT_EQ(SCALE_FACTOR_100P, GetScaleFactorFromScale(1.0f));
+ EXPECT_EQ(SCALE_FACTOR_100P, GetScaleFactorFromScale(1.39f));
+ EXPECT_EQ(SCALE_FACTOR_180P, GetScaleFactorFromScale(1.41f));
+ EXPECT_EQ(SCALE_FACTOR_180P, GetScaleFactorFromScale(1.8f));
+ EXPECT_EQ(SCALE_FACTOR_180P, GetScaleFactorFromScale(2.0f));
+ EXPECT_EQ(SCALE_FACTOR_180P, GetScaleFactorFromScale(999.0f));
+}
+
+TEST(LayoutTest, GetScaleFactorFromScaleAllSupported) {
+ std::vector<ScaleFactor> supported_factors;
+ for (int factor = SCALE_FACTOR_100P; factor < NUM_SCALE_FACTORS; ++factor) {
+ supported_factors.push_back(static_cast<ScaleFactor>(factor));
+ }
+ test::ScopedSetSupportedScaleFactors scoped_supported(supported_factors);
+
+ EXPECT_EQ(SCALE_FACTOR_100P, GetScaleFactorFromScale(0.1f));
+ EXPECT_EQ(SCALE_FACTOR_100P, GetScaleFactorFromScale(0.9f));
+ EXPECT_EQ(SCALE_FACTOR_100P, GetScaleFactorFromScale(1.0f));
+ EXPECT_EQ(SCALE_FACTOR_125P, GetScaleFactorFromScale(1.19f));
+ EXPECT_EQ(SCALE_FACTOR_125P, GetScaleFactorFromScale(1.21f));
+ EXPECT_EQ(SCALE_FACTOR_133P, GetScaleFactorFromScale(1.291f));
+ EXPECT_EQ(SCALE_FACTOR_133P, GetScaleFactorFromScale(1.3f));
+ EXPECT_EQ(SCALE_FACTOR_140P, GetScaleFactorFromScale(1.4f));
+ EXPECT_EQ(SCALE_FACTOR_150P, GetScaleFactorFromScale(1.59f));
+ EXPECT_EQ(SCALE_FACTOR_150P, GetScaleFactorFromScale(1.61f));
+ EXPECT_EQ(SCALE_FACTOR_180P, GetScaleFactorFromScale(1.7f));
+ EXPECT_EQ(SCALE_FACTOR_180P, GetScaleFactorFromScale(1.89f));
+ EXPECT_EQ(SCALE_FACTOR_200P, GetScaleFactorFromScale(1.91f));
+ EXPECT_EQ(SCALE_FACTOR_200P, GetScaleFactorFromScale(2.0f));
+ EXPECT_EQ(SCALE_FACTOR_200P, GetScaleFactorFromScale(2.1f));
+ EXPECT_EQ(SCALE_FACTOR_200P, GetScaleFactorFromScale(999.0f));
+}
+
+TEST(LayoutTest, GetMaxScaleFactor) {
+#if defined(OS_CHROMEOS)
+ // On Chrome OS, the maximum scale factor is based on
+ // the available resource pack. In testing environment,
+ // we always have 200P.
+ EXPECT_EQ(SCALE_FACTOR_200P, GetMaxScaleFactor());
+#else
+ {
+ ScaleFactor scale_factors[] = { SCALE_FACTOR_100P };
+ std::vector<ScaleFactor> supported_factors(
+ scale_factors, scale_factors + arraysize(scale_factors));
+ test::ScopedSetSupportedScaleFactors scoped_supported(supported_factors);
+ EXPECT_EQ(SCALE_FACTOR_100P, GetMaxScaleFactor());
+ }
+
+ {
+ ScaleFactor scale_factors[] = { SCALE_FACTOR_100P,
+ SCALE_FACTOR_140P };
+ std::vector<ScaleFactor> supported_factors(
+ scale_factors, scale_factors + arraysize(scale_factors));
+ test::ScopedSetSupportedScaleFactors scoped_supported(supported_factors);
+ EXPECT_EQ(SCALE_FACTOR_140P, GetMaxScaleFactor());
+ }
+
+ {
+ ScaleFactor scale_factors[] = { SCALE_FACTOR_200P,
+ SCALE_FACTOR_180P,
+ SCALE_FACTOR_140P,
+ SCALE_FACTOR_100P };
+ std::vector<ScaleFactor> supported_factors(
+ scale_factors, scale_factors + arraysize(scale_factors));
+ test::ScopedSetSupportedScaleFactors scoped_supported(supported_factors);
+ EXPECT_EQ(SCALE_FACTOR_200P, GetMaxScaleFactor());
+ }
+#endif
+}
+
+} // namespace ui
« no previous file with comments | « ui/base/layout.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698