| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium OS 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 <vector> | 5 #include <vector> |
| 6 | 6 |
| 7 #include <gflags/gflags.h> | 7 #include <gflags/gflags.h> |
| 8 #include <gtest/gtest.h> | 8 #include <gtest/gtest.h> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 ASSERT_TRUE((str = stacker.GetUnder("a2")) != NULL); | 74 ASSERT_TRUE((str = stacker.GetUnder("a2")) != NULL); |
| 75 EXPECT_EQ("b", *str); | 75 EXPECT_EQ("b", *str); |
| 76 | 76 |
| 77 stacker.AddAbove("a3", "a2"); | 77 stacker.AddAbove("a3", "a2"); |
| 78 stacker.AddAbove("b3", "b2"); | 78 stacker.AddAbove("b3", "b2"); |
| 79 stacker.AddAbove("d3", "d"); | 79 stacker.AddAbove("d3", "d"); |
| 80 CheckStackerOutput(stacker.items(), "a3 a2 b b3 b2 c2 d3 d"); | 80 CheckStackerOutput(stacker.items(), "a3 a2 b b3 b2 c2 d3 d"); |
| 81 } | 81 } |
| 82 | 82 |
| 83 TEST_F(UtilTest, ByteMap) { | 83 TEST_F(UtilTest, ByteMap) { |
| 84 int width = 4, height = 3; | 84 Size size(4, 3); |
| 85 ByteMap bytemap(width, height); | 85 ByteMap bytemap(size); |
| 86 EXPECT_EQ(width, bytemap.width()); | 86 EXPECT_EQ(size, bytemap.size()); |
| 87 EXPECT_EQ(height, bytemap.height()); | |
| 88 EXPECT_PRED_FORMAT3( | 87 EXPECT_PRED_FORMAT3( |
| 89 BytesAreEqual, | 88 BytesAreEqual, |
| 90 reinterpret_cast<unsigned const char*>("\x00\x00\x00\x00" | 89 reinterpret_cast<unsigned const char*>("\x00\x00\x00\x00" |
| 91 "\x00\x00\x00\x00" | 90 "\x00\x00\x00\x00" |
| 92 "\x00\x00\x00\x00"), | 91 "\x00\x00\x00\x00"), |
| 93 bytemap.bytes(), | 92 bytemap.bytes(), |
| 94 width * height); | 93 size.area()); |
| 95 | 94 |
| 96 // Set a few rectangles that are bogus or fall entirely outside of the | 95 // Set a few rectangles that are bogus or fall entirely outside of the |
| 97 // region. | 96 // region. |
| 98 bytemap.SetRectangle(-width, 0, width, height, 0xff); | 97 bytemap.SetRectangle(Rect(-size.width, 0, size.width, size.height), 0xff); |
| 99 bytemap.SetRectangle(width, 0, width, height, 0xff); | 98 bytemap.SetRectangle(Rect(size.width, 0, size.width, size.height), 0xff); |
| 100 bytemap.SetRectangle(0, -height, width, height, 0xff); | 99 bytemap.SetRectangle(Rect(0, -size.height, size.width, size.height), 0xff); |
| 101 bytemap.SetRectangle(0, height, width, height, 0xff); | 100 bytemap.SetRectangle(Rect(0, size.height, size.width, size.height), 0xff); |
| 102 bytemap.SetRectangle(0, 0, width, -1, 0xff); | 101 bytemap.SetRectangle(Rect(0, 0, size.width, -1), 0xff); |
| 103 bytemap.SetRectangle(0, 0, -1, height, 0xff); | 102 bytemap.SetRectangle(Rect(0, 0, -1, size.height), 0xff); |
| 104 EXPECT_PRED_FORMAT3( | 103 EXPECT_PRED_FORMAT3( |
| 105 BytesAreEqual, | 104 BytesAreEqual, |
| 106 reinterpret_cast<unsigned const char*>("\x00\x00\x00\x00" | 105 reinterpret_cast<unsigned const char*>("\x00\x00\x00\x00" |
| 107 "\x00\x00\x00\x00" | 106 "\x00\x00\x00\x00" |
| 108 "\x00\x00\x00\x00"), | 107 "\x00\x00\x00\x00"), |
| 109 bytemap.bytes(), | 108 bytemap.bytes(), |
| 110 width * height); | 109 size.area()); |
| 111 | 110 |
| 112 // Set a few rectangles that partially cover the region and then one | 111 // Set a few rectangles that partially cover the region and then one |
| 113 // that matches its size. | 112 // that matches its size. |
| 114 bytemap.SetRectangle(-2, -3, 3, 4, 0xf0); | 113 bytemap.SetRectangle(Rect(-2, -3, 3, 4), 0xf0); |
| 115 EXPECT_PRED_FORMAT3( | 114 EXPECT_PRED_FORMAT3( |
| 116 BytesAreEqual, | 115 BytesAreEqual, |
| 117 reinterpret_cast<unsigned const char*>("\xf0\x00\x00\x00" | 116 reinterpret_cast<unsigned const char*>("\xf0\x00\x00\x00" |
| 118 "\x00\x00\x00\x00" | 117 "\x00\x00\x00\x00" |
| 119 "\x00\x00\x00\x00"), | 118 "\x00\x00\x00\x00"), |
| 120 bytemap.bytes(), | 119 bytemap.bytes(), |
| 121 width * height); | 120 size.area()); |
| 122 bytemap.SetRectangle(width - 3, height - 1, 10, 10, 0xff); | 121 bytemap.SetRectangle(Rect(size.width - 3, size.height - 1, 10, 10), 0xff); |
| 123 EXPECT_PRED_FORMAT3( | 122 EXPECT_PRED_FORMAT3( |
| 124 BytesAreEqual, | 123 BytesAreEqual, |
| 125 reinterpret_cast<unsigned const char*>("\xf0\x00\x00\x00" | 124 reinterpret_cast<unsigned const char*>("\xf0\x00\x00\x00" |
| 126 "\x00\x00\x00\x00" | 125 "\x00\x00\x00\x00" |
| 127 "\x00\xff\xff\xff"), | 126 "\x00\xff\xff\xff"), |
| 128 bytemap.bytes(), | 127 bytemap.bytes(), |
| 129 width * height); | 128 size.area()); |
| 130 bytemap.SetRectangle(0, 0, width, height, 0xaa); | 129 bytemap.SetRectangle(Rect(0, 0, size.width, size.height), 0xaa); |
| 131 EXPECT_PRED_FORMAT3( | 130 EXPECT_PRED_FORMAT3( |
| 132 BytesAreEqual, | 131 BytesAreEqual, |
| 133 reinterpret_cast<unsigned const char*>("\xaa\xaa\xaa\xaa" | 132 reinterpret_cast<unsigned const char*>("\xaa\xaa\xaa\xaa" |
| 134 "\xaa\xaa\xaa\xaa" | 133 "\xaa\xaa\xaa\xaa" |
| 135 "\xaa\xaa\xaa\xaa"), | 134 "\xaa\xaa\xaa\xaa"), |
| 136 bytemap.bytes(), | 135 bytemap.bytes(), |
| 137 width * height); | 136 size.area()); |
| 138 | 137 |
| 139 // Now clear the map to a particular value. | 138 // Now clear the map to a particular value. |
| 140 bytemap.Clear(0x01); | 139 bytemap.Clear(0x01); |
| 141 EXPECT_PRED_FORMAT3( | 140 EXPECT_PRED_FORMAT3( |
| 142 BytesAreEqual, | 141 BytesAreEqual, |
| 143 reinterpret_cast<unsigned const char*>("\x01\x01\x01\x01" | 142 reinterpret_cast<unsigned const char*>("\x01\x01\x01\x01" |
| 144 "\x01\x01\x01\x01" | 143 "\x01\x01\x01\x01" |
| 145 "\x01\x01\x01\x01"), | 144 "\x01\x01\x01\x01"), |
| 146 bytemap.bytes(), | 145 bytemap.bytes(), |
| 147 width * height); | 146 size.area()); |
| 148 } | 147 } |
| 149 | 148 |
| 150 } // namespace window_manager | 149 } // namespace window_manager |
| 151 | 150 |
| 152 int main(int argc, char** argv) { | 151 int main(int argc, char** argv) { |
| 153 return window_manager::InitAndRunTests(&argc, argv, &FLAGS_logtostderr); | 152 return window_manager::InitAndRunTests(&argc, argv, &FLAGS_logtostderr); |
| 154 } | 153 } |
| OLD | NEW |