Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(54)

Side by Side Diff: chrome/common/render_messages_unittest.cc

Issue 2121004: Windows accessibility improvements: 1. All WebKit roles are now passed to the... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/common/render_messages_internal.h ('k') | chrome/renderer/render_view.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 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 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 "base/scoped_ptr.h" 5 #include "base/scoped_ptr.h"
6 #include "base/string16.h" 6 #include "base/string16.h"
7 #include "base/values.h" 7 #include "base/values.h"
8 #include "chrome/common/render_messages.h" 8 #include "chrome/common/render_messages.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
11 TEST(RenderMessagesUnittest, WebAccessibility) { 11 TEST(RenderMessagesUnittest, WebAccessibility) {
12 // Test a simple case. 12 // Test a simple case.
13 webkit_glue::WebAccessibility input; 13 webkit_glue::WebAccessibility input;
14 input.id = 123; 14 input.id = 123;
15 input.name = ASCIIToUTF16("name"); 15 input.name = ASCIIToUTF16("name");
16 input.value = ASCIIToUTF16("value"); 16 input.value = ASCIIToUTF16("value");
17 input.action = ASCIIToUTF16("action"); 17 string16 help = ASCIIToUTF16("help");
18 input.description = ASCIIToUTF16("description"); 18 input.attributes[webkit_glue::WebAccessibility::ATTR_HELP] = help;
19 input.help = ASCIIToUTF16("help"); 19 input.role = webkit_glue::WebAccessibility::ROLE_CHECKBOX;
20 input.shortcut = ASCIIToUTF16("shortcut");
21 input.role = webkit_glue::WebAccessibility::ROLE_CHECKBUTTON;
22 input.state = 20 input.state =
23 (1 << webkit_glue::WebAccessibility::STATE_CHECKED) | 21 (1 << webkit_glue::WebAccessibility::STATE_CHECKED) |
24 (1 << webkit_glue::WebAccessibility::STATE_FOCUSED); 22 (1 << webkit_glue::WebAccessibility::STATE_FOCUSED);
25 input.location = WebKit::WebRect(11, 22, 333, 444); 23 input.location = WebKit::WebRect(11, 22, 333, 444);
26 24
27 IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL); 25 IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL);
28 IPC::WriteParam(&msg, input); 26 IPC::WriteParam(&msg, input);
29 27
30 webkit_glue::WebAccessibility output; 28 webkit_glue::WebAccessibility output;
31 void* iter = NULL; 29 void* iter = NULL;
32 EXPECT_TRUE(IPC::ReadParam(&msg, &iter, &output)); 30 EXPECT_TRUE(IPC::ReadParam(&msg, &iter, &output));
33 EXPECT_EQ(input.id, output.id); 31 EXPECT_EQ(input.id, output.id);
34 EXPECT_EQ(input.name, output.name); 32 EXPECT_EQ(input.name, output.name);
35 EXPECT_EQ(input.value, output.value); 33 EXPECT_EQ(input.value, output.value);
36 EXPECT_EQ(input.action, output.action); 34 EXPECT_EQ(static_cast<size_t>(1), input.attributes.size());
37 EXPECT_EQ(input.description, output.description); 35 EXPECT_EQ(help, input.attributes[webkit_glue::WebAccessibility::ATTR_HELP]);
38 EXPECT_EQ(input.help, output.help);
39 EXPECT_EQ(input.shortcut, output.shortcut);
40 EXPECT_EQ(input.role, output.role); 36 EXPECT_EQ(input.role, output.role);
41 EXPECT_EQ(input.state, output.state); 37 EXPECT_EQ(input.state, output.state);
42 EXPECT_EQ(input.location, output.location); 38 EXPECT_EQ(input.location, output.location);
43 EXPECT_EQ(input.children.size(), output.children.size()); 39 EXPECT_EQ(input.children.size(), output.children.size());
44 40
45 // Test a corrupt case. 41 // Test a corrupt case.
46 IPC::Message bad_msg(1, 2, IPC::Message::PRIORITY_NORMAL); 42 IPC::Message bad_msg(1, 2, IPC::Message::PRIORITY_NORMAL);
47 bad_msg.WriteInt(99); 43 bad_msg.WriteInt(99);
48 iter = NULL; 44 iter = NULL;
49 EXPECT_FALSE(IPC::ReadParam(&bad_msg, &iter, &output)); 45 EXPECT_FALSE(IPC::ReadParam(&bad_msg, &iter, &output));
50 46
51 // Test a recursive case. 47 // Test a recursive case.
52 webkit_glue::WebAccessibility outer; 48 webkit_glue::WebAccessibility outer;
53 outer.id = 1000; 49 outer.id = 1000;
54 outer.name = ASCIIToUTF16("outer_name"); 50 outer.name = ASCIIToUTF16("outer_name");
55 outer.role = webkit_glue::WebAccessibility::ROLE_GROUPING; 51 outer.role = webkit_glue::WebAccessibility::ROLE_GROUP;
56 outer.state = 0; 52 outer.state = 0;
57 outer.location = WebKit::WebRect(0, 0, 1000, 1000); 53 outer.location = WebKit::WebRect(0, 0, 1000, 1000);
58 webkit_glue::WebAccessibility inner1; 54 webkit_glue::WebAccessibility inner1;
59 inner1.id = 1001; 55 inner1.id = 1001;
60 inner1.name = ASCIIToUTF16("inner1_name"); 56 inner1.name = ASCIIToUTF16("inner1_name");
61 inner1.role = webkit_glue::WebAccessibility::ROLE_RADIOBUTTON; 57 inner1.role = webkit_glue::WebAccessibility::ROLE_RADIO_BUTTON;
62 inner1.state = 58 inner1.state =
63 (1 << webkit_glue::WebAccessibility::STATE_CHECKED) | 59 (1 << webkit_glue::WebAccessibility::STATE_CHECKED) |
64 (1 << webkit_glue::WebAccessibility::STATE_FOCUSED); 60 (1 << webkit_glue::WebAccessibility::STATE_FOCUSED);
65 inner1.location = WebKit::WebRect(10, 10, 900, 400); 61 inner1.location = WebKit::WebRect(10, 10, 900, 400);
66 outer.children.push_back(inner1); 62 outer.children.push_back(inner1);
67 webkit_glue::WebAccessibility inner2; 63 webkit_glue::WebAccessibility inner2;
68 inner2.id = 1002; 64 inner2.id = 1002;
69 inner2.name = ASCIIToUTF16("inner2_name"); 65 inner2.name = ASCIIToUTF16("inner2_name");
70 inner2.role = webkit_glue::WebAccessibility::ROLE_RADIOBUTTON; 66 inner2.role = webkit_glue::WebAccessibility::ROLE_RADIO_BUTTON;
71 inner2.state = (1 << webkit_glue::WebAccessibility::STATE_CHECKED); 67 inner2.state = (1 << webkit_glue::WebAccessibility::STATE_CHECKED);
72 inner2.location = WebKit::WebRect(10, 500, 900, 400); 68 inner2.location = WebKit::WebRect(10, 500, 900, 400);
73 outer.children.push_back(inner2); 69 outer.children.push_back(inner2);
74 70
75 IPC::Message msg2(1, 2, IPC::Message::PRIORITY_NORMAL); 71 IPC::Message msg2(1, 2, IPC::Message::PRIORITY_NORMAL);
76 IPC::WriteParam(&msg2, outer); 72 IPC::WriteParam(&msg2, outer);
77 73
78 void* iter2 = NULL; 74 void* iter2 = NULL;
79 EXPECT_TRUE(IPC::ReadParam(&msg2, &iter2, &output)); 75 EXPECT_TRUE(IPC::ReadParam(&msg2, &iter2, &output));
80 EXPECT_EQ(outer.id, output.id); 76 EXPECT_EQ(outer.id, output.id);
81 EXPECT_EQ(outer.name, output.name); 77 EXPECT_EQ(outer.name, output.name);
82 EXPECT_EQ(outer.role, output.role); 78 EXPECT_EQ(outer.role, output.role);
83 EXPECT_EQ(outer.state, output.state); 79 EXPECT_EQ(outer.state, output.state);
84 EXPECT_EQ(outer.location, output.location); 80 EXPECT_EQ(outer.location, output.location);
85 EXPECT_EQ(outer.children.size(), output.children.size()); 81 EXPECT_EQ(outer.children.size(), output.children.size());
86 EXPECT_EQ(inner1.id, output.children[0].id); 82 EXPECT_EQ(inner1.id, output.children[0].id);
87 EXPECT_EQ(inner1.name, output.children[0].name); 83 EXPECT_EQ(inner1.name, output.children[0].name);
88 EXPECT_EQ(inner1.role, output.children[0].role); 84 EXPECT_EQ(inner1.role, output.children[0].role);
89 EXPECT_EQ(inner1.state, output.children[0].state); 85 EXPECT_EQ(inner1.state, output.children[0].state);
90 EXPECT_EQ(inner1.location, output.children[0].location); 86 EXPECT_EQ(inner1.location, output.children[0].location);
91 EXPECT_EQ(inner2.id, output.children[1].id); 87 EXPECT_EQ(inner2.id, output.children[1].id);
92 EXPECT_EQ(inner2.name, output.children[1].name); 88 EXPECT_EQ(inner2.name, output.children[1].name);
93 EXPECT_EQ(inner2.role, output.children[1].role); 89 EXPECT_EQ(inner2.role, output.children[1].role);
94 EXPECT_EQ(inner2.state, output.children[1].state); 90 EXPECT_EQ(inner2.state, output.children[1].state);
95 EXPECT_EQ(inner2.location, output.children[1].location); 91 EXPECT_EQ(inner2.location, output.children[1].location);
96 } 92 }
OLDNEW
« no previous file with comments | « chrome/common/render_messages_internal.h ('k') | chrome/renderer/render_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698