Updates the mic icon status based on the device's audio state (2nd)
[chromium-blink-merge.git] / chrome / browser / chromeos / ui / accessibility_focus_ring_controller_unittest.cc
blob8054780a8894d383eb48e89f55d71f04d950512a
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/chromeos/ui/accessibility_focus_ring_controller.h"
7 #include "testing/gtest/include/gtest/gtest.h"
9 namespace chromeos {
11 class TestableAccessibilityFocusRingController
12 : public AccessibilityFocusRingController {
13 public:
14 TestableAccessibilityFocusRingController() {
15 // By default use an easy round number for testing.
16 margin_ = 10;
18 virtual ~TestableAccessibilityFocusRingController() {}
20 void RectsToRings(const std::vector<gfx::Rect>& rects,
21 std::vector<AccessibilityFocusRing>* rings) const {
22 AccessibilityFocusRingController::RectsToRings(rects, rings);
25 virtual int GetMargin() const override {
26 return margin_;
29 private:
30 int margin_;
33 class AccessibilityFocusRingControllerTest : public testing::Test {
34 public:
35 AccessibilityFocusRingControllerTest() {}
36 virtual ~AccessibilityFocusRingControllerTest() {}
38 protected:
39 gfx::Rect AddMargin(gfx::Rect r) {
40 r.Inset(-controller_.GetMargin(), -controller_.GetMargin());
41 return r;
44 TestableAccessibilityFocusRingController controller_;
47 TEST_F(AccessibilityFocusRingControllerTest, RectsToRingsSimpleBoundsCheck) {
48 // Easy sanity check. Given a single rectangle, make sure we get back
49 // a focus ring with the same bounds.
50 std::vector<gfx::Rect> rects;
51 rects.push_back(gfx::Rect(10, 30, 70, 150));
52 std::vector<AccessibilityFocusRing> rings;
53 controller_.RectsToRings(rects, &rings);
54 ASSERT_EQ(1U, rings.size());
55 ASSERT_EQ(AddMargin(rects[0]), rings[0].GetBounds());
58 TEST_F(AccessibilityFocusRingControllerTest, RectsToRingsVerticalStack) {
59 // Given two rects, one on top of each other, we should get back a
60 // focus ring that surrounds them both.
61 std::vector<gfx::Rect> rects;
62 rects.push_back(gfx::Rect(10, 10, 60, 30));
63 rects.push_back(gfx::Rect(10, 40, 60, 30));
64 std::vector<AccessibilityFocusRing> rings;
65 controller_.RectsToRings(rects, &rings);
66 ASSERT_EQ(1U, rings.size());
67 ASSERT_EQ(AddMargin(gfx::Rect(10, 10, 60, 60)), rings[0].GetBounds());
70 TEST_F(AccessibilityFocusRingControllerTest, RectsToRingsHorizontalStack) {
71 // Given two rects, one next to the other horizontally, we should get back a
72 // focus ring that surrounds them both.
73 std::vector<gfx::Rect> rects;
74 rects.push_back(gfx::Rect(10, 10, 60, 30));
75 rects.push_back(gfx::Rect(70, 10, 60, 30));
76 std::vector<AccessibilityFocusRing> rings;
77 controller_.RectsToRings(rects, &rings);
78 ASSERT_EQ(1U, rings.size());
79 ASSERT_EQ(AddMargin(gfx::Rect(10, 10, 120, 30)), rings[0].GetBounds());
82 TEST_F(AccessibilityFocusRingControllerTest, RectsToRingsParagraphShape) {
83 // Given a simple paragraph shape, make sure we get something that
84 // outlines it correctly.
85 std::vector<gfx::Rect> rects;
86 rects.push_back(gfx::Rect(10, 10, 180, 80));
87 rects.push_back(gfx::Rect(10, 110, 580, 280));
88 rects.push_back(gfx::Rect(410, 410, 180, 80));
89 std::vector<AccessibilityFocusRing> rings;
90 controller_.RectsToRings(rects, &rings);
91 ASSERT_EQ(1U, rings.size());
92 EXPECT_EQ(gfx::Rect(0, 0, 600, 500), rings[0].GetBounds());
94 const gfx::Point* points = rings[0].points;
95 EXPECT_EQ(gfx::Point(0, 90), points[0]);
96 EXPECT_EQ(gfx::Point(0, 10), points[1]);
97 EXPECT_EQ(gfx::Point(0, 0), points[2]);
98 EXPECT_EQ(gfx::Point(10, 0), points[3]);
99 EXPECT_EQ(gfx::Point(190, 0), points[4]);
100 EXPECT_EQ(gfx::Point(200, 0), points[5]);
101 EXPECT_EQ(gfx::Point(200, 10), points[6]);
102 EXPECT_EQ(gfx::Point(200, 90), points[7]);
103 EXPECT_EQ(gfx::Point(200, 100), points[8]);
104 EXPECT_EQ(gfx::Point(210, 100), points[9]);
105 EXPECT_EQ(gfx::Point(590, 100), points[10]);
106 EXPECT_EQ(gfx::Point(600, 100), points[11]);
107 EXPECT_EQ(gfx::Point(600, 110), points[12]);
108 EXPECT_EQ(gfx::Point(600, 390), points[13]);
109 EXPECT_EQ(gfx::Point(600, 400), points[14]);
110 EXPECT_EQ(gfx::Point(600, 400), points[15]);
111 EXPECT_EQ(gfx::Point(600, 400), points[16]);
112 EXPECT_EQ(gfx::Point(600, 400), points[17]);
113 EXPECT_EQ(gfx::Point(600, 410), points[18]);
114 EXPECT_EQ(gfx::Point(600, 490), points[19]);
115 EXPECT_EQ(gfx::Point(600, 500), points[20]);
116 EXPECT_EQ(gfx::Point(590, 500), points[21]);
117 EXPECT_EQ(gfx::Point(410, 500), points[22]);
118 EXPECT_EQ(gfx::Point(400, 500), points[23]);
119 EXPECT_EQ(gfx::Point(400, 490), points[24]);
120 EXPECT_EQ(gfx::Point(400, 410), points[25]);
121 EXPECT_EQ(gfx::Point(400, 400), points[26]);
122 EXPECT_EQ(gfx::Point(390, 400), points[27]);
123 EXPECT_EQ(gfx::Point(10, 400), points[28]);
124 EXPECT_EQ(gfx::Point(0, 400), points[29]);
125 EXPECT_EQ(gfx::Point(0, 390), points[30]);
126 EXPECT_EQ(gfx::Point(0, 110), points[31]);
127 EXPECT_EQ(gfx::Point(0, 100), points[32]);
128 EXPECT_EQ(gfx::Point(0, 100), points[33]);
129 EXPECT_EQ(gfx::Point(0, 100), points[34]);
130 EXPECT_EQ(gfx::Point(0, 100), points[35]);
133 } // namespace chromeos