| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // #include "ash/display/display_util.h" |
| 6 |
| 7 #include "ui/display/manager/display_manager_utilities.h" |
| 8 |
| 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 |
| 11 //#include "ash/root_window_controller.h" |
| 12 //#include "ash/shell.h" |
| 13 //#include "ash/test/ash_test_base.h" |
| 14 //#include "ash/test/display_manager_test_api.h" |
| 15 |
| 16 namespace display { |
| 17 |
| 18 // typedef test::AshTestBase DisplayUtilTest; |
| 19 |
| 20 namespace { |
| 21 |
| 22 class ScopedSetInternalDisplayId { |
| 23 public: |
| 24 ScopedSetInternalDisplayId(int64_t); |
| 25 ~ScopedSetInternalDisplayId(); |
| 26 }; |
| 27 |
| 28 ScopedSetInternalDisplayId::ScopedSetInternalDisplayId(int64_t id) { |
| 29 display::Display::SetInternalDisplayId(id); |
| 30 } |
| 31 |
| 32 ScopedSetInternalDisplayId::~ScopedSetInternalDisplayId() { |
| 33 display::Display::SetInternalDisplayId(display::Display::kInvalidDisplayID); |
| 34 } |
| 35 |
| 36 } // namespace |
| 37 |
| 38 TEST(DisplayUtilitiesTest, GenerateDisplayIdList) { |
| 39 display::DisplayIdList list; |
| 40 { |
| 41 int64_t ids[] = {10, 1}; |
| 42 list = GenerateDisplayIdList(std::begin(ids), std::end(ids)); |
| 43 EXPECT_EQ(1, list[0]); |
| 44 EXPECT_EQ(10, list[1]); |
| 45 |
| 46 int64_t three_ids[] = {10, 5, 1}; |
| 47 list = GenerateDisplayIdList(std::begin(three_ids), std::end(three_ids)); |
| 48 ASSERT_EQ(3u, list.size()); |
| 49 EXPECT_EQ(1, list[0]); |
| 50 EXPECT_EQ(5, list[1]); |
| 51 EXPECT_EQ(10, list[2]); |
| 52 } |
| 53 { |
| 54 int64_t ids[] = {10, 100}; |
| 55 list = GenerateDisplayIdList(std::begin(ids), std::end(ids)); |
| 56 EXPECT_EQ(10, list[0]); |
| 57 EXPECT_EQ(100, list[1]); |
| 58 |
| 59 int64_t three_ids[] = {10, 100, 1000}; |
| 60 list = GenerateDisplayIdList(std::begin(three_ids), std::end(three_ids)); |
| 61 ASSERT_EQ(3u, list.size()); |
| 62 EXPECT_EQ(10, list[0]); |
| 63 EXPECT_EQ(100, list[1]); |
| 64 EXPECT_EQ(1000, list[2]); |
| 65 } |
| 66 { |
| 67 ScopedSetInternalDisplayId set_internal(100); |
| 68 int64_t ids[] = {10, 100}; |
| 69 list = GenerateDisplayIdList(std::begin(ids), std::end(ids)); |
| 70 EXPECT_EQ(100, list[0]); |
| 71 EXPECT_EQ(10, list[1]); |
| 72 |
| 73 std::swap(ids[0], ids[1]); |
| 74 list = GenerateDisplayIdList(std::begin(ids), std::end(ids)); |
| 75 EXPECT_EQ(100, list[0]); |
| 76 EXPECT_EQ(10, list[1]); |
| 77 |
| 78 int64_t three_ids[] = {10, 100, 1000}; |
| 79 list = GenerateDisplayIdList(std::begin(three_ids), std::end(three_ids)); |
| 80 ASSERT_EQ(3u, list.size()); |
| 81 EXPECT_EQ(100, list[0]); |
| 82 EXPECT_EQ(10, list[1]); |
| 83 EXPECT_EQ(1000, list[2]); |
| 84 } |
| 85 { |
| 86 ScopedSetInternalDisplayId set_internal(10); |
| 87 int64_t ids[] = {10, 100}; |
| 88 list = GenerateDisplayIdList(std::begin(ids), std::end(ids)); |
| 89 EXPECT_EQ(10, list[0]); |
| 90 EXPECT_EQ(100, list[1]); |
| 91 |
| 92 std::swap(ids[0], ids[1]); |
| 93 list = GenerateDisplayIdList(std::begin(ids), std::end(ids)); |
| 94 EXPECT_EQ(10, list[0]); |
| 95 EXPECT_EQ(100, list[1]); |
| 96 |
| 97 int64_t three_ids[] = {10, 100, 1000}; |
| 98 list = GenerateDisplayIdList(std::begin(three_ids), std::end(three_ids)); |
| 99 ASSERT_EQ(3u, list.size()); |
| 100 EXPECT_EQ(10, list[0]); |
| 101 EXPECT_EQ(100, list[1]); |
| 102 EXPECT_EQ(1000, list[2]); |
| 103 } |
| 104 } |
| 105 |
| 106 TEST(DisplayUtilitiesTest, DisplayIdListToString) { |
| 107 { |
| 108 int64_t ids[] = {10, 1, 16}; |
| 109 display::DisplayIdList list = |
| 110 GenerateDisplayIdList(std::begin(ids), std::end(ids)); |
| 111 EXPECT_EQ("1,10,16", DisplayIdListToString(list)); |
| 112 } |
| 113 { |
| 114 ScopedSetInternalDisplayId set_internal(16); |
| 115 int64_t ids[] = {10, 1, 16}; |
| 116 display::DisplayIdList list = |
| 117 GenerateDisplayIdList(std::begin(ids), std::end(ids)); |
| 118 EXPECT_EQ("16,1,10", DisplayIdListToString(list)); |
| 119 } |
| 120 } |
| 121 |
| 122 } // namespace display |
| OLD | NEW |