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

Unified Diff: ash/display/display_change_observer_chromeos_unittest.cc

Issue 23286003: ash: Get output info from chromeos instead of XRandR. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: use index from XRandR 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 | « ash/display/display_change_observer_chromeos.cc ('k') | ash/display/display_change_observer_x11.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/display/display_change_observer_chromeos_unittest.cc
diff --git a/ash/display/display_util_x11_unittest.cc b/ash/display/display_change_observer_chromeos_unittest.cc
similarity index 31%
rename from ash/display/display_util_x11_unittest.cc
rename to ash/display/display_change_observer_chromeos_unittest.cc
index f534a28dcbbb3b978160ac898cf5cc7383172357..dc8d492742d9884045f150649168fdcaa359603d 100644
--- a/ash/display/display_util_x11_unittest.cc
+++ b/ash/display/display_change_observer_chromeos_unittest.cc
@@ -2,77 +2,60 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "ash/display/display_util_x11.h"
-
-#include <X11/extensions/Xrandr.h>
-
-// Undefine X's macros used in gtest.
-#undef Bool
-#undef None
+#include "ash/display/display_change_observer_chromeos.h"
+#include "ash/display/display_info.h"
+#include "chromeos/display/output_configurator.h"
#include "chromeos/display/output_util.h"
#include "testing/gtest/include/gtest/gtest.h"
-typedef testing::Test DisplayUtilX11Test;
+using chromeos::OutputConfigurator;
+
+typedef testing::Test DisplayChangeObserverTest;
namespace ash {
namespace internal {
-TEST_F(DisplayUtilX11Test, TestBlackListedDisplay) {
- EXPECT_TRUE(ShouldIgnoreSize(10, 10));
- EXPECT_TRUE(ShouldIgnoreSize(40, 30));
- EXPECT_TRUE(ShouldIgnoreSize(50, 40));
- EXPECT_TRUE(ShouldIgnoreSize(160, 90));
- EXPECT_TRUE(ShouldIgnoreSize(160, 100));
+TEST_F(DisplayChangeObserverTest, TestBlackListedDisplay) {
+ EXPECT_TRUE(DisplayChangeObserver::ShouldIgnoreSize(10, 10));
+ EXPECT_TRUE(DisplayChangeObserver::ShouldIgnoreSize(40, 30));
+ EXPECT_TRUE(DisplayChangeObserver::ShouldIgnoreSize(50, 40));
+ EXPECT_TRUE(DisplayChangeObserver::ShouldIgnoreSize(160, 90));
+ EXPECT_TRUE(DisplayChangeObserver::ShouldIgnoreSize(160, 100));
- EXPECT_FALSE(ShouldIgnoreSize(50, 60));
- EXPECT_FALSE(ShouldIgnoreSize(100, 70));
- EXPECT_FALSE(ShouldIgnoreSize(272, 181));
+ EXPECT_FALSE(DisplayChangeObserver::ShouldIgnoreSize(50, 60));
+ EXPECT_FALSE(DisplayChangeObserver::ShouldIgnoreSize(100, 70));
+ EXPECT_FALSE(DisplayChangeObserver::ShouldIgnoreSize(272, 181));
}
-TEST_F(DisplayUtilX11Test, GetResolutionList) {
- XRRScreenResources resources = {0};
- RROutput outputs[] = {1};
- resources.noutput = arraysize(outputs);
- resources.outputs = outputs;
- XRRModeInfo modes[] = {
- // id, width, height, interlaced, refresh rate
- chromeos::test::CreateModeInfo(11, 1920, 1200, false, 60.0f),
-
- // different rates
- chromeos::test::CreateModeInfo(12, 1920, 1080, false, 30.0f),
- chromeos::test::CreateModeInfo(13, 1920, 1080, false, 50.0f),
- chromeos::test::CreateModeInfo(14, 1920, 1080, false, 40.0f),
-
- // interlace vs non interlace
- chromeos::test::CreateModeInfo(15, 1280, 720, true, 60.0f),
- chromeos::test::CreateModeInfo(16, 1280, 720, false, 40.0f),
-
- // interlace only
- chromeos::test::CreateModeInfo(17, 1024, 768, true, 40.0f),
- chromeos::test::CreateModeInfo(18, 1024, 768, true, 60.0f),
-
- // mixed
- chromeos::test::CreateModeInfo(19, 1024, 600, true, 60.0f),
- chromeos::test::CreateModeInfo(20, 1024, 600, false, 40.0f),
- chromeos::test::CreateModeInfo(21, 1024, 600, false, 50.0f),
-
- // just one interlaced mode
- chromeos::test::CreateModeInfo(22, 640, 480, true, 60.0f),
- };
- resources.nmode = arraysize(modes);
- resources.modes = modes;
-
- XRROutputInfo output_info = {0};
- RRMode output_modes[] = {
- 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22
- };
- output_info.nmode = arraysize(output_modes);
- output_info.modes = output_modes;
+TEST_F(DisplayChangeObserverTest, GetResolutionList) {
+ OutputConfigurator::OutputSnapshot output;
+ output.mode_infos[11] = OutputConfigurator::ModeInfo(1920, 1200, false);
+
+ // All non-interlaced (as would be seen with different refresh rates).
+ output.mode_infos[12] = OutputConfigurator::ModeInfo(1920, 1080, false);
+ output.mode_infos[13] = OutputConfigurator::ModeInfo(1920, 1080, false);
+ output.mode_infos[14] = OutputConfigurator::ModeInfo(1920, 1080, false);
+
+ // Interlaced vs non-interlaced.
+ output.mode_infos[15] = OutputConfigurator::ModeInfo(1280, 720, true);
+ output.mode_infos[16] = OutputConfigurator::ModeInfo(1280, 720, false);
+
+ // Interlaced only.
+ output.mode_infos[17] = OutputConfigurator::ModeInfo(1024, 768, true);
+ output.mode_infos[18] = OutputConfigurator::ModeInfo(1024, 768, true);
+
+ // Mixed.
+ output.mode_infos[19] = OutputConfigurator::ModeInfo(1024, 600, true);
+ output.mode_infos[20] = OutputConfigurator::ModeInfo(1024, 600, false);
+ output.mode_infos[21] = OutputConfigurator::ModeInfo(1024, 600, false);
+
+ // Just one interlaced mode.
+ output.mode_infos[22] = OutputConfigurator::ModeInfo(640, 480, true);
std::vector<Resolution> resolutions =
- GetResolutionList(&resources, &output_info);
- EXPECT_EQ(6u, resolutions.size());
+ DisplayChangeObserver::GetResolutionList(output);
+ ASSERT_EQ(6u, resolutions.size());
EXPECT_EQ("1920x1200", resolutions[0].size.ToString());
EXPECT_FALSE(resolutions[0].interlaced);
@@ -91,12 +74,9 @@ TEST_F(DisplayUtilX11Test, GetResolutionList) {
EXPECT_EQ("640x480", resolutions[5].size.ToString());
EXPECT_TRUE(resolutions[5].interlaced);
- // Empty output shouldn't crash.
- RRMode empty_output_modes[] = {};
- output_info.nmode = 0;
- output_info.modes = empty_output_modes;
-
- resolutions = GetResolutionList(&resources, &output_info);
+ // Outputs without any modes shouldn't cause a crash.
+ output.mode_infos.clear();
+ resolutions = DisplayChangeObserver::GetResolutionList(output);
EXPECT_EQ(0u, resolutions.size());
}
« no previous file with comments | « ash/display/display_change_observer_chromeos.cc ('k') | ash/display/display_change_observer_x11.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698