| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 "ui/display/manager/display_manager_utilities.h" | 5 #include "ui/display/manager/display_manager_utilities.h" |
| 6 | 6 |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 #include "ui/display/display.h" | 8 #include "ui/display/display.h" |
| 9 #include "ui/display/types/display_constants.h" | 9 #include "ui/display/types/display_constants.h" |
| 10 | 10 |
| 11 namespace display { | 11 namespace display { |
| 12 | 12 |
| 13 namespace { | 13 namespace { |
| 14 | 14 |
| 15 class ScopedSetInternalDisplayId { | 15 class ScopedSetInternalDisplayId { |
| 16 public: | 16 public: |
| 17 ScopedSetInternalDisplayId(int64_t); | 17 ScopedSetInternalDisplayId(int64_t); |
| 18 ~ScopedSetInternalDisplayId(); | 18 ~ScopedSetInternalDisplayId(); |
| 19 }; | 19 }; |
| 20 | 20 |
| 21 ScopedSetInternalDisplayId::ScopedSetInternalDisplayId(int64_t id) { | 21 ScopedSetInternalDisplayId::ScopedSetInternalDisplayId(int64_t id) { |
| 22 display::Display::SetInternalDisplayId(id); | 22 Display::SetInternalDisplayId(id); |
| 23 } | 23 } |
| 24 | 24 |
| 25 ScopedSetInternalDisplayId::~ScopedSetInternalDisplayId() { | 25 ScopedSetInternalDisplayId::~ScopedSetInternalDisplayId() { |
| 26 display::Display::SetInternalDisplayId(kInvalidDisplayId); | 26 Display::SetInternalDisplayId(kInvalidDisplayId); |
| 27 } | 27 } |
| 28 | 28 |
| 29 } // namespace | 29 } // namespace |
| 30 | 30 |
| 31 TEST(DisplayUtilitiesTest, GenerateDisplayIdList) { | 31 TEST(DisplayUtilitiesTest, GenerateDisplayIdList) { |
| 32 display::DisplayIdList list; | 32 DisplayIdList list; |
| 33 { | 33 { |
| 34 int64_t ids[] = {10, 1}; | 34 int64_t ids[] = {10, 1}; |
| 35 list = GenerateDisplayIdList(std::begin(ids), std::end(ids)); | 35 list = GenerateDisplayIdList(std::begin(ids), std::end(ids)); |
| 36 EXPECT_EQ(1, list[0]); | 36 EXPECT_EQ(1, list[0]); |
| 37 EXPECT_EQ(10, list[1]); | 37 EXPECT_EQ(10, list[1]); |
| 38 | 38 |
| 39 int64_t three_ids[] = {10, 5, 1}; | 39 int64_t three_ids[] = {10, 5, 1}; |
| 40 list = GenerateDisplayIdList(std::begin(three_ids), std::end(three_ids)); | 40 list = GenerateDisplayIdList(std::begin(three_ids), std::end(three_ids)); |
| 41 ASSERT_EQ(3u, list.size()); | 41 ASSERT_EQ(3u, list.size()); |
| 42 EXPECT_EQ(1, list[0]); | 42 EXPECT_EQ(1, list[0]); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 ASSERT_EQ(3u, list.size()); | 92 ASSERT_EQ(3u, list.size()); |
| 93 EXPECT_EQ(10, list[0]); | 93 EXPECT_EQ(10, list[0]); |
| 94 EXPECT_EQ(100, list[1]); | 94 EXPECT_EQ(100, list[1]); |
| 95 EXPECT_EQ(1000, list[2]); | 95 EXPECT_EQ(1000, list[2]); |
| 96 } | 96 } |
| 97 } | 97 } |
| 98 | 98 |
| 99 TEST(DisplayUtilitiesTest, DisplayIdListToString) { | 99 TEST(DisplayUtilitiesTest, DisplayIdListToString) { |
| 100 { | 100 { |
| 101 int64_t ids[] = {10, 1, 16}; | 101 int64_t ids[] = {10, 1, 16}; |
| 102 display::DisplayIdList list = | 102 DisplayIdList list = GenerateDisplayIdList(std::begin(ids), std::end(ids)); |
| 103 GenerateDisplayIdList(std::begin(ids), std::end(ids)); | |
| 104 EXPECT_EQ("1,10,16", DisplayIdListToString(list)); | 103 EXPECT_EQ("1,10,16", DisplayIdListToString(list)); |
| 105 } | 104 } |
| 106 { | 105 { |
| 107 ScopedSetInternalDisplayId set_internal(16); | 106 ScopedSetInternalDisplayId set_internal(16); |
| 108 int64_t ids[] = {10, 1, 16}; | 107 int64_t ids[] = {10, 1, 16}; |
| 109 display::DisplayIdList list = | 108 DisplayIdList list = GenerateDisplayIdList(std::begin(ids), std::end(ids)); |
| 110 GenerateDisplayIdList(std::begin(ids), std::end(ids)); | |
| 111 EXPECT_EQ("16,1,10", DisplayIdListToString(list)); | 109 EXPECT_EQ("16,1,10", DisplayIdListToString(list)); |
| 112 } | 110 } |
| 113 } | 111 } |
| 114 | 112 |
| 115 } // namespace display | 113 } // namespace display |
| OLD | NEW |