| 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 "testing/gtest/include/gtest/gtest.h" | 5 #include "testing/gtest/include/gtest/gtest.h" |
| 6 #include "ui/ozone/platform/dri/dri_buffer.h" | 6 #include "ui/ozone/platform/dri/dri_buffer.h" |
| 7 #include "ui/ozone/platform/dri/hardware_display_controller.h" | 7 #include "ui/ozone/platform/dri/hardware_display_controller.h" |
| 8 #include "ui/ozone/platform/dri/screen_manager.h" | 8 #include "ui/ozone/platform/dri/screen_manager.h" |
| 9 #include "ui/ozone/platform/dri/test/mock_dri_wrapper.h" | 9 #include "ui/ozone/platform/dri/test/mock_dri_wrapper.h" |
| 10 | 10 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 | 68 |
| 69 private: | 69 private: |
| 70 DISALLOW_COPY_AND_ASSIGN(ScreenManagerTest); | 70 DISALLOW_COPY_AND_ASSIGN(ScreenManagerTest); |
| 71 }; | 71 }; |
| 72 | 72 |
| 73 TEST_F(ScreenManagerTest, CheckWithNoControllers) { | 73 TEST_F(ScreenManagerTest, CheckWithNoControllers) { |
| 74 EXPECT_FALSE(screen_manager_->GetDisplayController(GetPrimaryBounds())); | 74 EXPECT_FALSE(screen_manager_->GetDisplayController(GetPrimaryBounds())); |
| 75 } | 75 } |
| 76 | 76 |
| 77 TEST_F(ScreenManagerTest, CheckWithValidController) { | 77 TEST_F(ScreenManagerTest, CheckWithValidController) { |
| 78 screen_manager_->AddDisplayController( | 78 screen_manager_->AddDisplayController(dri_.get(), kPrimaryCrtc, |
| 79 dri_.get(), kPrimaryCrtc, kPrimaryConnector); | 79 kPrimaryConnector); |
| 80 screen_manager_->ConfigureDisplayController(kPrimaryCrtc, | 80 screen_manager_->ConfigureDisplayController(kPrimaryCrtc, |
| 81 kPrimaryConnector, | 81 kPrimaryConnector, |
| 82 GetPrimaryBounds().origin(), | 82 GetPrimaryBounds().origin(), |
| 83 kDefaultMode); | 83 kDefaultMode); |
| 84 base::WeakPtr<ui::HardwareDisplayController> controller = | 84 base::WeakPtr<ui::HardwareDisplayController> controller = |
| 85 screen_manager_->GetDisplayController(GetPrimaryBounds()); | 85 screen_manager_->GetDisplayController(GetPrimaryBounds()); |
| 86 | 86 |
| 87 EXPECT_TRUE(controller); | 87 EXPECT_TRUE(controller); |
| 88 EXPECT_TRUE(controller->HasCrtc(kPrimaryCrtc)); | 88 EXPECT_TRUE(controller->HasCrtc(kPrimaryCrtc)); |
| 89 } | 89 } |
| 90 | 90 |
| 91 TEST_F(ScreenManagerTest, CheckWithInvalidBounds) { | 91 TEST_F(ScreenManagerTest, CheckWithInvalidBounds) { |
| 92 screen_manager_->AddDisplayController( | 92 screen_manager_->AddDisplayController(dri_.get(), kPrimaryCrtc, |
| 93 dri_.get(), kPrimaryCrtc, kPrimaryConnector); | 93 kPrimaryConnector); |
| 94 screen_manager_->ConfigureDisplayController(kPrimaryCrtc, | 94 screen_manager_->ConfigureDisplayController(kPrimaryCrtc, |
| 95 kPrimaryConnector, | 95 kPrimaryConnector, |
| 96 GetPrimaryBounds().origin(), | 96 GetPrimaryBounds().origin(), |
| 97 kDefaultMode); | 97 kDefaultMode); |
| 98 | 98 |
| 99 EXPECT_TRUE(screen_manager_->GetDisplayController(GetPrimaryBounds())); | 99 EXPECT_TRUE(screen_manager_->GetDisplayController(GetPrimaryBounds())); |
| 100 EXPECT_FALSE(screen_manager_->GetDisplayController(GetSecondaryBounds())); | 100 EXPECT_FALSE(screen_manager_->GetDisplayController(GetSecondaryBounds())); |
| 101 } | 101 } |
| 102 | 102 |
| 103 TEST_F(ScreenManagerTest, CheckForSecondValidController) { | 103 TEST_F(ScreenManagerTest, CheckForSecondValidController) { |
| 104 screen_manager_->AddDisplayController( | 104 screen_manager_->AddDisplayController(dri_.get(), kPrimaryCrtc, |
| 105 dri_.get(), kPrimaryCrtc, kPrimaryConnector); | 105 kPrimaryConnector); |
| 106 screen_manager_->ConfigureDisplayController(kPrimaryCrtc, | 106 screen_manager_->ConfigureDisplayController(kPrimaryCrtc, |
| 107 kPrimaryConnector, | 107 kPrimaryConnector, |
| 108 GetPrimaryBounds().origin(), | 108 GetPrimaryBounds().origin(), |
| 109 kDefaultMode); | 109 kDefaultMode); |
| 110 screen_manager_->AddDisplayController( | 110 screen_manager_->AddDisplayController(dri_.get(), kSecondaryCrtc, |
| 111 dri_.get(), kSecondaryCrtc, kSecondaryConnector); | 111 kSecondaryConnector); |
| 112 screen_manager_->ConfigureDisplayController(kSecondaryCrtc, | 112 screen_manager_->ConfigureDisplayController( |
| 113 kSecondaryConnector, | 113 kSecondaryCrtc, kSecondaryConnector, GetSecondaryBounds().origin(), |
| 114 GetSecondaryBounds().origin(), | 114 kDefaultMode); |
| 115 kDefaultMode); | |
| 116 | 115 |
| 117 EXPECT_TRUE(screen_manager_->GetDisplayController(GetPrimaryBounds())); | 116 EXPECT_TRUE(screen_manager_->GetDisplayController(GetPrimaryBounds())); |
| 118 EXPECT_TRUE(screen_manager_->GetDisplayController(GetSecondaryBounds())); | 117 EXPECT_TRUE(screen_manager_->GetDisplayController(GetSecondaryBounds())); |
| 119 } | 118 } |
| 120 | 119 |
| 121 TEST_F(ScreenManagerTest, CheckControllerAfterItIsRemoved) { | 120 TEST_F(ScreenManagerTest, CheckControllerAfterItIsRemoved) { |
| 122 screen_manager_->AddDisplayController( | 121 screen_manager_->AddDisplayController(dri_.get(), kPrimaryCrtc, |
| 123 dri_.get(), kPrimaryCrtc, kPrimaryConnector); | 122 kPrimaryConnector); |
| 124 screen_manager_->ConfigureDisplayController(kPrimaryCrtc, | 123 screen_manager_->ConfigureDisplayController(kPrimaryCrtc, |
| 125 kPrimaryConnector, | 124 kPrimaryConnector, |
| 126 GetPrimaryBounds().origin(), | 125 GetPrimaryBounds().origin(), |
| 127 kDefaultMode); | 126 kDefaultMode); |
| 128 base::WeakPtr<ui::HardwareDisplayController> controller = | 127 base::WeakPtr<ui::HardwareDisplayController> controller = |
| 129 screen_manager_->GetDisplayController(GetPrimaryBounds()); | 128 screen_manager_->GetDisplayController(GetPrimaryBounds()); |
| 130 | 129 |
| 131 EXPECT_TRUE(controller); | 130 EXPECT_TRUE(controller); |
| 132 screen_manager_->RemoveDisplayController(kPrimaryCrtc); | 131 screen_manager_->RemoveDisplayController(kPrimaryCrtc); |
| 133 EXPECT_FALSE(controller); | 132 EXPECT_FALSE(controller); |
| 134 } | 133 } |
| 135 | 134 |
| 136 TEST_F(ScreenManagerTest, CheckDuplicateConfiguration) { | 135 TEST_F(ScreenManagerTest, CheckDuplicateConfiguration) { |
| 137 screen_manager_->AddDisplayController( | 136 screen_manager_->AddDisplayController(dri_.get(), kPrimaryCrtc, |
| 138 dri_.get(), kPrimaryCrtc, kPrimaryConnector); | 137 kPrimaryConnector); |
| 139 screen_manager_->ConfigureDisplayController(kPrimaryCrtc, | 138 screen_manager_->ConfigureDisplayController(kPrimaryCrtc, |
| 140 kPrimaryConnector, | 139 kPrimaryConnector, |
| 141 GetPrimaryBounds().origin(), | 140 GetPrimaryBounds().origin(), |
| 142 kDefaultMode); | 141 kDefaultMode); |
| 143 screen_manager_->ConfigureDisplayController(kPrimaryCrtc, | 142 screen_manager_->ConfigureDisplayController(kPrimaryCrtc, |
| 144 kPrimaryConnector, | 143 kPrimaryConnector, |
| 145 GetPrimaryBounds().origin(), | 144 GetPrimaryBounds().origin(), |
| 146 kDefaultMode); | 145 kDefaultMode); |
| 147 | 146 |
| 148 EXPECT_TRUE(screen_manager_->GetDisplayController(GetPrimaryBounds())); | 147 EXPECT_TRUE(screen_manager_->GetDisplayController(GetPrimaryBounds())); |
| 149 EXPECT_FALSE(screen_manager_->GetDisplayController(GetSecondaryBounds())); | 148 EXPECT_FALSE(screen_manager_->GetDisplayController(GetSecondaryBounds())); |
| 150 } | 149 } |
| 151 | 150 |
| 152 TEST_F(ScreenManagerTest, CheckChangingMode) { | 151 TEST_F(ScreenManagerTest, CheckChangingMode) { |
| 153 screen_manager_->AddDisplayController( | 152 screen_manager_->AddDisplayController(dri_.get(), kPrimaryCrtc, |
| 154 dri_.get(), kPrimaryCrtc, kPrimaryConnector); | 153 kPrimaryConnector); |
| 155 screen_manager_->ConfigureDisplayController(kPrimaryCrtc, | 154 screen_manager_->ConfigureDisplayController(kPrimaryCrtc, |
| 156 kPrimaryConnector, | 155 kPrimaryConnector, |
| 157 GetPrimaryBounds().origin(), | 156 GetPrimaryBounds().origin(), |
| 158 kDefaultMode); | 157 kDefaultMode); |
| 159 drmModeModeInfo new_mode = kDefaultMode; | 158 drmModeModeInfo new_mode = kDefaultMode; |
| 160 new_mode.vdisplay = 10; | 159 new_mode.vdisplay = 10; |
| 161 screen_manager_->ConfigureDisplayController( | 160 screen_manager_->ConfigureDisplayController( |
| 162 kPrimaryCrtc, kPrimaryConnector, GetPrimaryBounds().origin(), new_mode); | 161 kPrimaryCrtc, kPrimaryConnector, GetPrimaryBounds().origin(), new_mode); |
| 163 | 162 |
| 164 gfx::Rect new_bounds(0, 0, new_mode.hdisplay, new_mode.vdisplay); | 163 gfx::Rect new_bounds(0, 0, new_mode.hdisplay, new_mode.vdisplay); |
| 165 EXPECT_TRUE(screen_manager_->GetDisplayController(new_bounds)); | 164 EXPECT_TRUE(screen_manager_->GetDisplayController(new_bounds)); |
| 166 EXPECT_FALSE(screen_manager_->GetDisplayController(GetSecondaryBounds())); | 165 EXPECT_FALSE(screen_manager_->GetDisplayController(GetSecondaryBounds())); |
| 167 drmModeModeInfo mode = | 166 drmModeModeInfo mode = |
| 168 screen_manager_->GetDisplayController(new_bounds)->get_mode(); | 167 screen_manager_->GetDisplayController(new_bounds)->get_mode(); |
| 169 EXPECT_EQ(new_mode.vdisplay, mode.vdisplay); | 168 EXPECT_EQ(new_mode.vdisplay, mode.vdisplay); |
| 170 EXPECT_EQ(new_mode.hdisplay, mode.hdisplay); | 169 EXPECT_EQ(new_mode.hdisplay, mode.hdisplay); |
| 171 } | 170 } |
| 172 | 171 |
| 173 TEST_F(ScreenManagerTest, CheckForControllersInMirroredMode) { | 172 TEST_F(ScreenManagerTest, CheckForControllersInMirroredMode) { |
| 174 screen_manager_->AddDisplayController( | 173 screen_manager_->AddDisplayController(dri_.get(), kPrimaryCrtc, |
| 175 dri_.get(), kPrimaryCrtc, kPrimaryConnector); | 174 kPrimaryConnector); |
| 176 screen_manager_->ConfigureDisplayController(kPrimaryCrtc, | 175 screen_manager_->ConfigureDisplayController(kPrimaryCrtc, |
| 177 kPrimaryConnector, | 176 kPrimaryConnector, |
| 178 GetPrimaryBounds().origin(), | 177 GetPrimaryBounds().origin(), |
| 179 kDefaultMode); | 178 kDefaultMode); |
| 180 screen_manager_->AddDisplayController( | 179 screen_manager_->AddDisplayController(dri_.get(), kSecondaryCrtc, |
| 181 dri_.get(), kSecondaryCrtc, kSecondaryConnector); | 180 kSecondaryConnector); |
| 182 screen_manager_->ConfigureDisplayController(kSecondaryCrtc, | 181 screen_manager_->ConfigureDisplayController(kSecondaryCrtc, |
| 183 kSecondaryConnector, | 182 kSecondaryConnector, |
| 184 GetPrimaryBounds().origin(), | 183 GetPrimaryBounds().origin(), |
| 185 kDefaultMode); | 184 kDefaultMode); |
| 186 | 185 |
| 187 EXPECT_TRUE(screen_manager_->GetDisplayController(GetPrimaryBounds())); | 186 EXPECT_TRUE(screen_manager_->GetDisplayController(GetPrimaryBounds())); |
| 188 EXPECT_FALSE(screen_manager_->GetDisplayController(GetSecondaryBounds())); | 187 EXPECT_FALSE(screen_manager_->GetDisplayController(GetSecondaryBounds())); |
| 189 } | 188 } |
| 190 | 189 |
| 191 TEST_F(ScreenManagerTest, CheckMirrorModeTransitions) { | 190 TEST_F(ScreenManagerTest, CheckMirrorModeTransitions) { |
| 192 screen_manager_->AddDisplayController( | 191 screen_manager_->AddDisplayController(dri_.get(), kPrimaryCrtc, |
| 193 dri_.get(), kPrimaryCrtc, kPrimaryConnector); | 192 kPrimaryConnector); |
| 194 screen_manager_->ConfigureDisplayController(kPrimaryCrtc, | 193 screen_manager_->ConfigureDisplayController(kPrimaryCrtc, |
| 195 kPrimaryConnector, | 194 kPrimaryConnector, |
| 196 GetPrimaryBounds().origin(), | 195 GetPrimaryBounds().origin(), |
| 197 kDefaultMode); | 196 kDefaultMode); |
| 198 screen_manager_->AddDisplayController( | 197 screen_manager_->AddDisplayController(dri_.get(), kSecondaryCrtc, |
| 199 dri_.get(), kSecondaryCrtc, kSecondaryConnector); | 198 kSecondaryConnector); |
| 200 screen_manager_->ConfigureDisplayController(kSecondaryCrtc, | 199 screen_manager_->ConfigureDisplayController(kSecondaryCrtc, |
| 201 kSecondaryConnector, | 200 kSecondaryConnector, |
| 202 GetSecondaryBounds().origin(), | 201 GetSecondaryBounds().origin(), |
| 203 kDefaultMode); | 202 kDefaultMode); |
| 204 | 203 |
| 205 EXPECT_TRUE(screen_manager_->GetDisplayController(GetPrimaryBounds())); | 204 EXPECT_TRUE(screen_manager_->GetDisplayController(GetPrimaryBounds())); |
| 206 EXPECT_TRUE(screen_manager_->GetDisplayController(GetSecondaryBounds())); | 205 EXPECT_TRUE(screen_manager_->GetDisplayController(GetSecondaryBounds())); |
| 207 | 206 |
| 208 screen_manager_->ConfigureDisplayController(kPrimaryCrtc, | 207 screen_manager_->ConfigureDisplayController(kPrimaryCrtc, |
| 209 kPrimaryConnector, | 208 kPrimaryConnector, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 222 kDefaultMode); | 221 kDefaultMode); |
| 223 screen_manager_->ConfigureDisplayController(kSecondaryCrtc, | 222 screen_manager_->ConfigureDisplayController(kSecondaryCrtc, |
| 224 kSecondaryConnector, | 223 kSecondaryConnector, |
| 225 GetPrimaryBounds().origin(), | 224 GetPrimaryBounds().origin(), |
| 226 kDefaultMode); | 225 kDefaultMode); |
| 227 EXPECT_TRUE(screen_manager_->GetDisplayController(GetPrimaryBounds())); | 226 EXPECT_TRUE(screen_manager_->GetDisplayController(GetPrimaryBounds())); |
| 228 EXPECT_TRUE(screen_manager_->GetDisplayController(GetSecondaryBounds())); | 227 EXPECT_TRUE(screen_manager_->GetDisplayController(GetSecondaryBounds())); |
| 229 } | 228 } |
| 230 | 229 |
| 231 TEST_F(ScreenManagerTest, MonitorGoneInMirrorMode) { | 230 TEST_F(ScreenManagerTest, MonitorGoneInMirrorMode) { |
| 232 screen_manager_->AddDisplayController( | 231 screen_manager_->AddDisplayController(dri_.get(), kPrimaryCrtc, |
| 233 dri_.get(), kPrimaryCrtc, kPrimaryConnector); | 232 kPrimaryConnector); |
| 234 screen_manager_->ConfigureDisplayController(kPrimaryCrtc, | 233 screen_manager_->ConfigureDisplayController(kPrimaryCrtc, |
| 235 kPrimaryConnector, | 234 kPrimaryConnector, |
| 236 GetPrimaryBounds().origin(), | 235 GetPrimaryBounds().origin(), |
| 237 kDefaultMode); | 236 kDefaultMode); |
| 238 screen_manager_->AddDisplayController( | 237 screen_manager_->AddDisplayController(dri_.get(), kSecondaryCrtc, |
| 239 dri_.get(), kSecondaryCrtc, kSecondaryConnector); | 238 kSecondaryConnector); |
| 240 screen_manager_->ConfigureDisplayController(kSecondaryCrtc, | 239 screen_manager_->ConfigureDisplayController(kSecondaryCrtc, |
| 241 kSecondaryConnector, | 240 kSecondaryConnector, |
| 242 GetPrimaryBounds().origin(), | 241 GetPrimaryBounds().origin(), |
| 243 kDefaultMode); | 242 kDefaultMode); |
| 244 | 243 |
| 245 screen_manager_->RemoveDisplayController(kSecondaryCrtc); | 244 screen_manager_->RemoveDisplayController(kSecondaryCrtc); |
| 246 EXPECT_TRUE( | 245 EXPECT_TRUE( |
| 247 screen_manager_->ConfigureDisplayController(kPrimaryCrtc, | 246 screen_manager_->ConfigureDisplayController(kPrimaryCrtc, |
| 248 kPrimaryConnector, | 247 kPrimaryConnector, |
| 249 GetPrimaryBounds().origin(), | 248 GetPrimaryBounds().origin(), |
| 250 kDefaultMode)); | 249 kDefaultMode)); |
| 251 EXPECT_TRUE(screen_manager_->GetDisplayController(GetPrimaryBounds())); | 250 EXPECT_TRUE(screen_manager_->GetDisplayController(GetPrimaryBounds())); |
| 252 EXPECT_FALSE(screen_manager_->GetDisplayController(GetSecondaryBounds())); | 251 EXPECT_FALSE(screen_manager_->GetDisplayController(GetSecondaryBounds())); |
| 253 } | 252 } |
| OLD | NEW |