Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ash/display/display_manager.h" | 5 #include "ash/display/display_manager.h" |
| 6 | 6 |
| 7 #include "ash/ash_switches.h" | |
| 7 #include "ash/display/display_controller.h" | 8 #include "ash/display/display_controller.h" |
| 8 #include "ash/display/display_layout_store.h" | 9 #include "ash/display/display_layout_store.h" |
| 9 #include "ash/screen_util.h" | 10 #include "ash/screen_util.h" |
| 10 #include "ash/shell.h" | 11 #include "ash/shell.h" |
| 11 #include "ash/test/ash_test_base.h" | 12 #include "ash/test/ash_test_base.h" |
| 12 #include "ash/test/display_manager_test_api.h" | 13 #include "ash/test/display_manager_test_api.h" |
| 13 #include "ash/test/mirror_window_test_api.h" | 14 #include "ash/test/mirror_window_test_api.h" |
| 15 #include "base/command_line.h" | |
| 14 #include "base/format_macros.h" | 16 #include "base/format_macros.h" |
| 15 #include "base/strings/string_number_conversions.h" | 17 #include "base/strings/string_number_conversions.h" |
| 16 #include "base/strings/stringprintf.h" | 18 #include "base/strings/stringprintf.h" |
| 17 #include "ui/aura/env.h" | 19 #include "ui/aura/env.h" |
| 18 #include "ui/aura/window_observer.h" | 20 #include "ui/aura/window_observer.h" |
| 19 #include "ui/aura/window_tree_host.h" | 21 #include "ui/aura/window_tree_host.h" |
| 20 #include "ui/events/test/event_generator.h" | 22 #include "ui/events/test/event_generator.h" |
| 21 #include "ui/gfx/display.h" | 23 #include "ui/gfx/display.h" |
| 22 #include "ui/gfx/display_observer.h" | 24 #include "ui/gfx/display_observer.h" |
| 25 #include "ui/gfx/font_render_params.h" | |
| 23 #include "ui/gfx/screen.h" | 26 #include "ui/gfx/screen.h" |
| 24 #include "ui/gfx/screen_type_delegate.h" | 27 #include "ui/gfx/screen_type_delegate.h" |
| 25 | 28 |
| 26 namespace ash { | 29 namespace ash { |
| 27 | 30 |
| 28 using std::vector; | 31 using std::vector; |
| 29 using std::string; | 32 using std::string; |
| 30 | 33 |
| 31 using base::StringPrintf; | 34 using base::StringPrintf; |
| 32 | 35 |
| (...skipping 1341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1374 private: | 1377 private: |
| 1375 DISALLOW_COPY_AND_ASSIGN(ScreenShutdownTest); | 1378 DISALLOW_COPY_AND_ASSIGN(ScreenShutdownTest); |
| 1376 }; | 1379 }; |
| 1377 | 1380 |
| 1378 TEST_F(ScreenShutdownTest, ScreenAfterShutdown) { | 1381 TEST_F(ScreenShutdownTest, ScreenAfterShutdown) { |
| 1379 if (!SupportsMultipleDisplays()) | 1382 if (!SupportsMultipleDisplays()) |
| 1380 return; | 1383 return; |
| 1381 UpdateDisplay("500x300,800x400"); | 1384 UpdateDisplay("500x300,800x400"); |
| 1382 } | 1385 } |
| 1383 | 1386 |
| 1387 | |
| 1388 #if defined(OS_CHROMEOS) | |
| 1389 namespace { | |
| 1390 // A helper class that sets the display configuration and start ash. | |
|
Daniel Erat
2014/08/20 22:04:52
nit: s/start/starts/
oshima
2014/08/20 22:26:58
Done.
| |
| 1391 class FontTestHelper : public test::AshTestBase { | |
| 1392 public: | |
| 1393 enum DisplayType { | |
| 1394 INTERNAL, | |
| 1395 EXTERNAL | |
| 1396 }; | |
| 1397 | |
| 1398 FontTestHelper(float scale, DisplayType display_type) { | |
| 1399 gfx::ClearFontRenderParamsCacheForTest(); | |
| 1400 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | |
| 1401 if (display_type == INTERNAL) | |
| 1402 command_line->AppendSwitch(switches::kAshUseFirstDisplayAsInternal); | |
| 1403 command_line->AppendSwitchASCII(switches::kAshHostWindowBounds, | |
| 1404 StringPrintf("1000x800*%f", scale)); | |
| 1405 SetUp(); | |
| 1406 } | |
| 1407 | |
| 1408 virtual ~FontTestHelper() { | |
| 1409 TearDown(); | |
| 1410 } | |
| 1411 | |
| 1412 // test::AshTestBase: | |
| 1413 virtual void TestBody() OVERRIDE { | |
| 1414 NOTREACHED(); | |
| 1415 } | |
| 1416 | |
| 1417 private: | |
| 1418 DISALLOW_COPY_AND_ASSIGN(FontTestHelper); | |
| 1419 }; | |
| 1420 | |
| 1421 | |
| 1422 bool IsTextSubpixelPositioningEnabled() { | |
| 1423 gfx::FontRenderParams params = | |
| 1424 gfx::GetFontRenderParams(gfx::FontRenderParamsQuery(false), NULL); | |
| 1425 return params.subpixel_positioning; | |
| 1426 } | |
| 1427 | |
| 1428 } // namespace | |
| 1429 | |
| 1430 typedef testing::Test DisplayManagerFontTest; | |
| 1431 | |
| 1432 TEST_F(DisplayManagerFontTest, TextSubpixelPositioningWithDsf100Internal) { | |
| 1433 FontTestHelper helper(1.0f, FontTestHelper::INTERNAL); | |
| 1434 ASSERT_DOUBLE_EQ(1.0f, | |
| 1435 Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); | |
|
Daniel Erat
2014/08/20 22:04:52
nit: i think these are usually indented four space
oshima
2014/08/20 22:26:57
all fixed.
| |
| 1436 EXPECT_FALSE(IsTextSubpixelPositioningEnabled()); | |
| 1437 } | |
| 1438 | |
| 1439 TEST_F(DisplayManagerFontTest, TextSubpixelPositioningWithDsf125Internal) { | |
| 1440 FontTestHelper helper(1.25f, FontTestHelper::INTERNAL); | |
| 1441 ASSERT_DOUBLE_EQ(1.25f, | |
| 1442 Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); | |
| 1443 EXPECT_TRUE(IsTextSubpixelPositioningEnabled()); | |
| 1444 } | |
| 1445 | |
| 1446 TEST_F(DisplayManagerFontTest, TextSubpixelPositioningWithDsf200Internal) { | |
| 1447 FontTestHelper helper(2.0f, FontTestHelper::INTERNAL); | |
| 1448 ASSERT_DOUBLE_EQ(2.0f, | |
| 1449 Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); | |
| 1450 EXPECT_TRUE(IsTextSubpixelPositioningEnabled()); | |
| 1451 } | |
| 1452 | |
| 1453 TEST_F(DisplayManagerFontTest, TextSubpixelPositioningWithDsf100External) { | |
| 1454 FontTestHelper helper(1.0f, FontTestHelper::EXTERNAL); | |
| 1455 ASSERT_DOUBLE_EQ(1.0f, | |
| 1456 Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); | |
| 1457 EXPECT_FALSE(IsTextSubpixelPositioningEnabled()); | |
| 1458 } | |
| 1459 | |
| 1460 TEST_F(DisplayManagerFontTest, TextSubpixelPositioningWithDsf125External) { | |
| 1461 FontTestHelper helper(1.25f, FontTestHelper::EXTERNAL); | |
| 1462 ASSERT_DOUBLE_EQ(1.25f, | |
| 1463 Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); | |
| 1464 EXPECT_FALSE(IsTextSubpixelPositioningEnabled()); | |
| 1465 } | |
| 1466 | |
| 1467 TEST_F(DisplayManagerFontTest, TextSubpixelPositioningWithDsf200External) { | |
| 1468 FontTestHelper helper(2.0f, FontTestHelper::EXTERNAL); | |
| 1469 ASSERT_DOUBLE_EQ(2.0f, | |
| 1470 Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); | |
| 1471 EXPECT_FALSE(IsTextSubpixelPositioningEnabled()); | |
| 1472 } | |
| 1473 | |
| 1474 #endif // OS_CHROMEOS | |
| 1475 | |
| 1384 } // namespace ash | 1476 } // namespace ash |
| OLD | NEW |