| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_color_manager_chromeos.h" | 5 #include "ash/display/display_color_manager_chromeos.h" |
| 6 | 6 |
| 7 #include "base/files/file_util.h" | 7 #include "base/files/file_util.h" |
| 8 #include "base/memory/scoped_vector.h" | 8 #include "base/memory/scoped_vector.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 std::vector<const ui::DisplayMode*> modes; | 98 std::vector<const ui::DisplayMode*> modes; |
| 99 ui::DisplayMode mode(gfx::Size(1024, 768), false, 60.0f); | 99 ui::DisplayMode mode(gfx::Size(1024, 768), false, 60.0f); |
| 100 modes.push_back(&mode); | 100 modes.push_back(&mode); |
| 101 scoped_ptr<ui::TestDisplaySnapshot> snapshot = | 101 scoped_ptr<ui::TestDisplaySnapshot> snapshot = |
| 102 make_scoped_ptr(new ui::TestDisplaySnapshot( | 102 make_scoped_ptr(new ui::TestDisplaySnapshot( |
| 103 123, gfx::Point(0, 0), /* origin */ | 103 123, gfx::Point(0, 0), /* origin */ |
| 104 gfx::Size(0, 0), /* physical_size */ | 104 gfx::Size(0, 0), /* physical_size */ |
| 105 ui::DISPLAY_CONNECTION_TYPE_INTERNAL, /* type */ | 105 ui::DISPLAY_CONNECTION_TYPE_INTERNAL, /* type */ |
| 106 false, /* is_aspect_preserving_scaling */ | 106 false, /* is_aspect_preserving_scaling */ |
| 107 0x06af5c10, /* product_id */ | 107 0x06af5c10, /* product_id */ |
| 108 false, /* has_color_correction_matrix */ |
| 108 modes, /* modes */ | 109 modes, /* modes */ |
| 109 modes[0] /* current_mode */, | 110 modes[0] /* current_mode */, modes[0] /* native_mode */)); |
| 110 modes[0] /* native_mode */)); | |
| 111 std::vector<ui::DisplaySnapshot*> outputs; | 111 std::vector<ui::DisplaySnapshot*> outputs; |
| 112 outputs.push_back(snapshot.get()); | 112 outputs.push_back(snapshot.get()); |
| 113 native_display_delegate_->set_outputs(outputs); | 113 native_display_delegate_->set_outputs(outputs); |
| 114 | 114 |
| 115 configurator_.OnConfigurationChanged(); | 115 configurator_.OnConfigurationChanged(); |
| 116 EXPECT_TRUE(test_api_.TriggerConfigureTimeout()); | 116 EXPECT_TRUE(test_api_.TriggerConfigureTimeout()); |
| 117 log_->GetActionsAndClear(); | 117 log_->GetActionsAndClear(); |
| 118 | 118 |
| 119 RunBlockingPoolTask(); | 119 RunBlockingPoolTask(); |
| 120 | 120 |
| 121 EXPECT_TRUE(base::MatchPattern( | 121 EXPECT_TRUE(base::MatchPattern( |
| 122 log_->GetActionsAndClear(), | 122 log_->GetActionsAndClear(), |
| 123 "set_gamma_ramp(id=123,rgb[0]*rgb[255]=???????????\?)")); | 123 "set_color_correction(id=123,gamma[0]*gamma[255]=???????????\?)")); |
| 124 } |
| 125 |
| 126 TEST_F(DisplayColorManagerTest, VCGTOnlyWithPlatformCTM) { |
| 127 std::vector<const ui::DisplayMode*> modes; |
| 128 ui::DisplayMode mode(gfx::Size(1024, 768), false, 60.0f); |
| 129 modes.push_back(&mode); |
| 130 scoped_ptr<ui::TestDisplaySnapshot> snapshot = |
| 131 make_scoped_ptr(new ui::TestDisplaySnapshot( |
| 132 123, gfx::Point(0, 0), /* origin */ |
| 133 gfx::Size(0, 0), /* physical_size */ |
| 134 ui::DISPLAY_CONNECTION_TYPE_INTERNAL, /* type */ |
| 135 false, /* is_aspect_preserving_scaling */ |
| 136 0x06af5c10, /* product_id */ |
| 137 true, /* has_color_correction_matrix */ |
| 138 modes, /* modes */ |
| 139 modes[0] /* current_mode */, modes[0] /* native_mode */)); |
| 140 std::vector<ui::DisplaySnapshot*> outputs; |
| 141 outputs.push_back(snapshot.get()); |
| 142 native_display_delegate_->set_outputs(outputs); |
| 143 |
| 144 configurator_.OnConfigurationChanged(); |
| 145 EXPECT_TRUE(test_api_.TriggerConfigureTimeout()); |
| 146 log_->GetActionsAndClear(); |
| 147 |
| 148 RunBlockingPoolTask(); |
| 149 |
| 150 EXPECT_TRUE(base::MatchPattern( |
| 151 log_->GetActionsAndClear(), |
| 152 "set_color_correction(id=123,gamma[0]*gamma[255]=???????????\?)")); |
| 153 } |
| 154 |
| 155 TEST_F(DisplayColorManagerTest, FullWithPlatformCTM) { |
| 156 std::vector<const ui::DisplayMode*> modes; |
| 157 ui::DisplayMode mode(gfx::Size(1024, 768), false, 60.0f); |
| 158 modes.push_back(&mode); |
| 159 scoped_ptr<ui::TestDisplaySnapshot> snapshot = |
| 160 make_scoped_ptr(new ui::TestDisplaySnapshot( |
| 161 123, gfx::Point(0, 0), /* origin */ |
| 162 gfx::Size(0, 0), /* physical_size */ |
| 163 ui::DISPLAY_CONNECTION_TYPE_INTERNAL, /* type */ |
| 164 false, /* is_aspect_preserving_scaling */ |
| 165 0x4c834a42, /* product_id */ |
| 166 true, /* has_color_correction_matrix */ |
| 167 modes, /* modes */ |
| 168 modes[0] /* current_mode */, modes[0] /* native_mode */)); |
| 169 std::vector<ui::DisplaySnapshot*> outputs; |
| 170 outputs.push_back(snapshot.get()); |
| 171 native_display_delegate_->set_outputs(outputs); |
| 172 |
| 173 configurator_.OnConfigurationChanged(); |
| 174 EXPECT_TRUE(test_api_.TriggerConfigureTimeout()); |
| 175 log_->GetActionsAndClear(); |
| 176 |
| 177 RunBlockingPoolTask(); |
| 178 |
| 179 EXPECT_TRUE(base::MatchPattern( |
| 180 log_->GetActionsAndClear(), |
| 181 "set_color_correction(id=123,degamma[0]*gamma[0]*ctm[0]*ctm[8]*)")); |
| 182 } |
| 183 |
| 184 TEST_F(DisplayColorManagerTest, FullWithoutPlatformCTM) { |
| 185 std::vector<const ui::DisplayMode*> modes; |
| 186 ui::DisplayMode mode(gfx::Size(1024, 768), false, 60.0f); |
| 187 modes.push_back(&mode); |
| 188 scoped_ptr<ui::TestDisplaySnapshot> snapshot = |
| 189 make_scoped_ptr(new ui::TestDisplaySnapshot( |
| 190 123, gfx::Point(0, 0), /* origin */ |
| 191 gfx::Size(0, 0), /* physical_size */ |
| 192 ui::DISPLAY_CONNECTION_TYPE_INTERNAL, /* type */ |
| 193 false, /* is_aspect_preserving_scaling */ |
| 194 0x4c834a42, /* product_id */ |
| 195 false, /* has_color_correction_matrix */ |
| 196 modes, /* modes */ |
| 197 modes[0] /* current_mode */, modes[0] /* native_mode */)); |
| 198 std::vector<ui::DisplaySnapshot*> outputs; |
| 199 outputs.push_back(snapshot.get()); |
| 200 native_display_delegate_->set_outputs(outputs); |
| 201 |
| 202 configurator_.OnConfigurationChanged(); |
| 203 EXPECT_TRUE(test_api_.TriggerConfigureTimeout()); |
| 204 log_->GetActionsAndClear(); |
| 205 |
| 206 RunBlockingPoolTask(); |
| 207 EXPECT_STREQ("", log_->GetActionsAndClear().c_str()); |
| 124 } | 208 } |
| 125 | 209 |
| 126 TEST_F(DisplayColorManagerTest, NoMatchProductID) { | 210 TEST_F(DisplayColorManagerTest, NoMatchProductID) { |
| 127 std::vector<const ui::DisplayMode*> modes; | 211 std::vector<const ui::DisplayMode*> modes; |
| 128 ui::DisplayMode mode(gfx::Size(1024, 768), false, 60.0f); | 212 ui::DisplayMode mode(gfx::Size(1024, 768), false, 60.0f); |
| 129 modes.push_back(&mode); | 213 modes.push_back(&mode); |
| 130 scoped_ptr<ui::TestDisplaySnapshot> snapshot = | 214 scoped_ptr<ui::TestDisplaySnapshot> snapshot = |
| 131 make_scoped_ptr(new ui::TestDisplaySnapshot( | 215 make_scoped_ptr(new ui::TestDisplaySnapshot( |
| 132 123, gfx::Point(0, 0), /* origin */ | 216 123, gfx::Point(0, 0), /* origin */ |
| 133 gfx::Size(0, 0), /* physical_size */ | 217 gfx::Size(0, 0), /* physical_size */ |
| 134 ui::DISPLAY_CONNECTION_TYPE_INTERNAL, /* type */ | 218 ui::DISPLAY_CONNECTION_TYPE_INTERNAL, /* type */ |
| 135 false, /* is_aspect_preserving_scaling */ | 219 false, /* is_aspect_preserving_scaling */ |
| 136 0, /* product_id */ | 220 0, /* product_id */ |
| 221 false, /* has_color_correction_matrix */ |
| 137 modes, /* modes */ | 222 modes, /* modes */ |
| 138 modes[0] /* current_mode */, | 223 modes[0] /* current_mode */, modes[0] /* native_mode */)); |
| 139 modes[0] /* native_mode */)); | |
| 140 std::vector<ui::DisplaySnapshot*> outputs; | 224 std::vector<ui::DisplaySnapshot*> outputs; |
| 141 outputs.push_back(snapshot.get()); | 225 outputs.push_back(snapshot.get()); |
| 142 native_display_delegate_->set_outputs(outputs); | 226 native_display_delegate_->set_outputs(outputs); |
| 143 | 227 |
| 144 configurator_.OnConfigurationChanged(); | 228 configurator_.OnConfigurationChanged(); |
| 145 EXPECT_TRUE(test_api_.TriggerConfigureTimeout()); | 229 EXPECT_TRUE(test_api_.TriggerConfigureTimeout()); |
| 146 | 230 |
| 147 log_->GetActionsAndClear(); | 231 log_->GetActionsAndClear(); |
| 148 RunBlockingPoolTask(); | 232 RunBlockingPoolTask(); |
| 149 EXPECT_STREQ("", log_->GetActionsAndClear().c_str()); | 233 EXPECT_STREQ("", log_->GetActionsAndClear().c_str()); |
| 150 } | 234 } |
| 151 | 235 |
| 152 TEST_F(DisplayColorManagerTest, NoVCGT) { | 236 TEST_F(DisplayColorManagerTest, NoVCGT) { |
| 153 std::vector<const ui::DisplayMode*> modes; | 237 std::vector<const ui::DisplayMode*> modes; |
| 154 ui::DisplayMode mode(gfx::Size(1024, 768), false, 60.0f); | 238 ui::DisplayMode mode(gfx::Size(1024, 768), false, 60.0f); |
| 155 modes.push_back(&mode); | 239 modes.push_back(&mode); |
| 156 scoped_ptr<ui::TestDisplaySnapshot> snapshot = | 240 scoped_ptr<ui::TestDisplaySnapshot> snapshot = |
| 157 make_scoped_ptr(new ui::TestDisplaySnapshot( | 241 make_scoped_ptr(new ui::TestDisplaySnapshot( |
| 158 123, gfx::Point(0, 0), /* origin */ | 242 123, gfx::Point(0, 0), /* origin */ |
| 159 gfx::Size(0, 0), /* physical_size */ | 243 gfx::Size(0, 0), /* physical_size */ |
| 160 ui::DISPLAY_CONNECTION_TYPE_INTERNAL, /* type */ | 244 ui::DISPLAY_CONNECTION_TYPE_INTERNAL, /* type */ |
| 161 false, /* is_aspect_preserving_scaling */ | 245 false, /* is_aspect_preserving_scaling */ |
| 162 0x0dae3211, /* product_id */ | 246 0x0dae3211, /* product_id */ |
| 247 false, /* has_color_correction_matrix */ |
| 163 modes, /* modes */ | 248 modes, /* modes */ |
| 164 modes[0] /* current_mode */, | 249 modes[0] /* current_mode */, modes[0] /* native_mode */)); |
| 165 modes[0] /* native_mode */)); | |
| 166 std::vector<ui::DisplaySnapshot*> outputs; | 250 std::vector<ui::DisplaySnapshot*> outputs; |
| 167 outputs.push_back(snapshot.get()); | 251 outputs.push_back(snapshot.get()); |
| 168 native_display_delegate_->set_outputs(outputs); | 252 native_display_delegate_->set_outputs(outputs); |
| 169 | 253 |
| 170 configurator_.OnConfigurationChanged(); | 254 configurator_.OnConfigurationChanged(); |
| 171 EXPECT_TRUE(test_api_.TriggerConfigureTimeout()); | 255 EXPECT_TRUE(test_api_.TriggerConfigureTimeout()); |
| 172 | 256 |
| 173 log_->GetActionsAndClear(); | 257 log_->GetActionsAndClear(); |
| 174 RunBlockingPoolTask(); | 258 RunBlockingPoolTask(); |
| 175 EXPECT_STREQ("", log_->GetActionsAndClear().c_str()); | 259 EXPECT_STREQ("", log_->GetActionsAndClear().c_str()); |
| 176 } | 260 } |
| 177 | 261 |
| 178 } // namespace ash | 262 } // namespace ash |
| OLD | NEW |