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 #import <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
6 | 6 |
7 #include "base/mac/scoped_nsobject.h" | 7 #include "base/mac/scoped_nsobject.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 #include "ui/gfx/color_profile.h" | 9 #include "ui/gfx/color_profile.h" |
10 #include "ui/gfx/mac/coordinate_conversion.h" | 10 #include "ui/gfx/mac/coordinate_conversion.h" |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 EXPECT_FALSE(TestColorProfileForBounds(TestWindowBounds())); | 86 EXPECT_FALSE(TestColorProfileForBounds(TestWindowBounds())); |
87 } | 87 } |
88 | 88 |
89 TEST_F(ColorProfileTest, GetDisplayColorProfileForEmptyOffScreenBounds) { | 89 TEST_F(ColorProfileTest, GetDisplayColorProfileForEmptyOffScreenBounds) { |
90 MoveTestWindowTo(gfx::Rect(-100, -100, 0, 0)); | 90 MoveTestWindowTo(gfx::Rect(-100, -100, 0, 0)); |
91 EXPECT_TRUE(TestWindowBounds().IsEmpty()); | 91 EXPECT_TRUE(TestWindowBounds().IsEmpty()); |
92 EXPECT_FALSE(TestWindowOnScreen()); | 92 EXPECT_FALSE(TestWindowOnScreen()); |
93 EXPECT_FALSE(TestColorProfileForBounds(TestWindowBounds())); | 93 EXPECT_FALSE(TestColorProfileForBounds(TestWindowBounds())); |
94 } | 94 } |
95 | 95 |
| 96 bool TestColorProfileForWindow(NSWindow* window) { |
| 97 std::vector<char> color_profile; |
| 98 return gfx::GetDisplayColorProfile(window, &color_profile); |
| 99 } |
| 100 |
| 101 TEST_F(ColorProfileTest, GetDisplayColorProfileForOnScreenWindow) { |
| 102 MoveTestWindowTo(gfx::Rect(10, 10, 100, 100)); |
| 103 EXPECT_FALSE(TestWindowBounds().IsEmpty()); |
| 104 EXPECT_TRUE(TestWindowContainedOnScreen()); |
| 105 EXPECT_TRUE(TestColorProfileForWindow(test_window())); |
| 106 } |
| 107 |
| 108 TEST_F(ColorProfileTest, GetDisplayColorProfileForPartiallyOnScreenWindow) { |
| 109 MoveTestWindowTo(gfx::Rect(-50, -50, 80, 80)); |
| 110 EXPECT_FALSE(TestWindowBounds().IsEmpty()); |
| 111 EXPECT_TRUE(TestWindowOnScreen()); |
| 112 EXPECT_TRUE(TestColorProfileForWindow(test_window())); |
| 113 } |
| 114 |
| 115 TEST_F(ColorProfileTest, GetDisplayColorProfileForOffScreenWindow) { |
| 116 MoveTestWindowTo(gfx::Rect(-100, -100, 10, 10)); |
| 117 EXPECT_FALSE(TestWindowBounds().IsEmpty()); |
| 118 EXPECT_FALSE(TestWindowOnScreen()); |
| 119 EXPECT_TRUE(TestColorProfileForWindow(test_window())); |
| 120 } |
| 121 |
| 122 TEST_F(ColorProfileTest, GetDisplayColorProfileForEmptyOnScreenWindow) { |
| 123 MoveTestWindowTo(gfx::Rect(10, 10, 0, 0)); |
| 124 EXPECT_TRUE(TestWindowBounds().IsEmpty()); |
| 125 EXPECT_FALSE(TestWindowOnScreen()); |
| 126 EXPECT_FALSE(TestColorProfileForWindow(test_window())); |
| 127 } |
| 128 |
| 129 TEST_F(ColorProfileTest, GetDisplayColorProfileForEmptyOffScreenWindow) { |
| 130 MoveTestWindowTo(gfx::Rect(-100, -100, 0, 0)); |
| 131 EXPECT_TRUE(TestWindowBounds().IsEmpty()); |
| 132 EXPECT_FALSE(TestWindowOnScreen()); |
| 133 EXPECT_FALSE(TestColorProfileForWindow(test_window())); |
| 134 } |
| 135 |
| 136 TEST_F(ColorProfileTest, GetDisplayColorProfileForNullWindow) { |
| 137 EXPECT_FALSE(TestColorProfileForWindow(nullptr)); |
| 138 EXPECT_FALSE(TestColorProfileForWindow(nil)); |
| 139 } |
| 140 |
96 } // namespace | 141 } // namespace |
OLD | NEW |