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 |
| 1391 // A helper class that sets the display configuration and starts ash. |
| 1392 // This is to make sure the font configuration happens during ash |
| 1393 // initialization process. |
| 1394 class FontTestHelper : public test::AshTestBase { |
| 1395 public: |
| 1396 enum DisplayType { |
| 1397 INTERNAL, |
| 1398 EXTERNAL |
| 1399 }; |
| 1400 |
| 1401 FontTestHelper(float scale, DisplayType display_type) { |
| 1402 gfx::ClearFontRenderParamsCacheForTest(); |
| 1403 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 1404 if (display_type == INTERNAL) |
| 1405 command_line->AppendSwitch(switches::kAshUseFirstDisplayAsInternal); |
| 1406 command_line->AppendSwitchASCII(switches::kAshHostWindowBounds, |
| 1407 StringPrintf("1000x800*%f", scale)); |
| 1408 SetUp(); |
| 1409 } |
| 1410 |
| 1411 virtual ~FontTestHelper() { |
| 1412 TearDown(); |
| 1413 } |
| 1414 |
| 1415 // test::AshTestBase: |
| 1416 virtual void TestBody() OVERRIDE { |
| 1417 NOTREACHED(); |
| 1418 } |
| 1419 |
| 1420 private: |
| 1421 DISALLOW_COPY_AND_ASSIGN(FontTestHelper); |
| 1422 }; |
| 1423 |
| 1424 |
| 1425 bool IsTextSubpixelPositioningEnabled() { |
| 1426 gfx::FontRenderParams params = |
| 1427 gfx::GetFontRenderParams(gfx::FontRenderParamsQuery(false), NULL); |
| 1428 return params.subpixel_positioning; |
| 1429 } |
| 1430 |
| 1431 } // namespace |
| 1432 |
| 1433 typedef testing::Test DisplayManagerFontTest; |
| 1434 |
| 1435 TEST_F(DisplayManagerFontTest, TextSubpixelPositioningWithDsf100Internal) { |
| 1436 FontTestHelper helper(1.0f, FontTestHelper::INTERNAL); |
| 1437 ASSERT_DOUBLE_EQ( |
| 1438 1.0f, Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); |
| 1439 EXPECT_FALSE(IsTextSubpixelPositioningEnabled()); |
| 1440 } |
| 1441 |
| 1442 TEST_F(DisplayManagerFontTest, TextSubpixelPositioningWithDsf125Internal) { |
| 1443 FontTestHelper helper(1.25f, FontTestHelper::INTERNAL); |
| 1444 ASSERT_DOUBLE_EQ( |
| 1445 1.25f, Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); |
| 1446 EXPECT_TRUE(IsTextSubpixelPositioningEnabled()); |
| 1447 } |
| 1448 |
| 1449 TEST_F(DisplayManagerFontTest, TextSubpixelPositioningWithDsf200Internal) { |
| 1450 FontTestHelper helper(2.0f, FontTestHelper::INTERNAL); |
| 1451 ASSERT_DOUBLE_EQ( |
| 1452 2.0f, Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); |
| 1453 EXPECT_TRUE(IsTextSubpixelPositioningEnabled()); |
| 1454 } |
| 1455 |
| 1456 TEST_F(DisplayManagerFontTest, TextSubpixelPositioningWithDsf100External) { |
| 1457 FontTestHelper helper(1.0f, FontTestHelper::EXTERNAL); |
| 1458 ASSERT_DOUBLE_EQ( |
| 1459 1.0f, Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); |
| 1460 EXPECT_FALSE(IsTextSubpixelPositioningEnabled()); |
| 1461 } |
| 1462 |
| 1463 TEST_F(DisplayManagerFontTest, TextSubpixelPositioningWithDsf125External) { |
| 1464 FontTestHelper helper(1.25f, FontTestHelper::EXTERNAL); |
| 1465 ASSERT_DOUBLE_EQ( |
| 1466 1.25f, Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); |
| 1467 EXPECT_FALSE(IsTextSubpixelPositioningEnabled()); |
| 1468 } |
| 1469 |
| 1470 TEST_F(DisplayManagerFontTest, TextSubpixelPositioningWithDsf200External) { |
| 1471 FontTestHelper helper(2.0f, FontTestHelper::EXTERNAL); |
| 1472 ASSERT_DOUBLE_EQ( |
| 1473 2.0f, Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); |
| 1474 EXPECT_FALSE(IsTextSubpixelPositioningEnabled()); |
| 1475 } |
| 1476 |
| 1477 #endif // OS_CHROMEOS |
| 1478 |
1384 } // namespace ash | 1479 } // namespace ash |
OLD | NEW |