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

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

Issue 1989009: Revert 46842 - Reimplement accessibility of web content by caching the entire... (Closed) Base URL: svn://svn.chromium.org/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_thread.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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.
4
5 #include "base/scoped_ptr.h"
6 #include "base/string16.h"
7 #include "base/values.h"
8 #include "chrome/common/render_messages.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10
11 TEST(RenderMessagesUnittest, WebAccessibility) {
12 // Test a simple case.
13 webkit_glue::WebAccessibility input;
14 input.id = 123;
15 input.name = ASCIIToUTF16("name");
16 input.value = ASCIIToUTF16("value");
17 input.action = ASCIIToUTF16("action");
18 input.description = ASCIIToUTF16("description");
19 input.help = ASCIIToUTF16("help");
20 input.shortcut = ASCIIToUTF16("shortcut");
21 input.role = webkit_glue::WebAccessibility::ROLE_CHECKBUTTON;
22 input.state =
23 (1 << webkit_glue::WebAccessibility::STATE_CHECKED) |
24 (1 << webkit_glue::WebAccessibility::STATE_FOCUSED);
25 input.location = WebKit::WebRect(11, 22, 333, 444);
26
27 IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL);
28 IPC::WriteParam(&msg, input);
29
30 webkit_glue::WebAccessibility output;
31 void* iter = NULL;
32 EXPECT_TRUE(IPC::ReadParam(&msg, &iter, &output));
33 EXPECT_EQ(input.id, output.id);
34 EXPECT_EQ(input.name, output.name);
35 EXPECT_EQ(input.value, output.value);
36 EXPECT_EQ(input.action, output.action);
37 EXPECT_EQ(input.description, output.description);
38 EXPECT_EQ(input.help, output.help);
39 EXPECT_EQ(input.shortcut, output.shortcut);
40 EXPECT_EQ(input.role, output.role);
41 EXPECT_EQ(input.state, output.state);
42 EXPECT_EQ(input.location, output.location);
43 EXPECT_EQ(input.children.size(), output.children.size());
44
45 // Test a corrupt case.
46 IPC::Message bad_msg(1, 2, IPC::Message::PRIORITY_NORMAL);
47 bad_msg.WriteInt(99);
48 iter = NULL;
49 EXPECT_FALSE(IPC::ReadParam(&bad_msg, &iter, &output));
50
51 // Test a recursive case.
52 webkit_glue::WebAccessibility outer;
53 outer.id = 1000;
54 outer.name = ASCIIToUTF16("outer_name");
55 outer.role = webkit_glue::WebAccessibility::ROLE_GROUPING;
56 outer.state = 0;
57 outer.location = WebKit::WebRect(0, 0, 1000, 1000);
58 webkit_glue::WebAccessibility inner1;
59 inner1.id = 1001;
60 inner1.name = ASCIIToUTF16("inner1_name");
61 inner1.role = webkit_glue::WebAccessibility::ROLE_RADIOBUTTON;
62 inner1.state =
63 (1 << webkit_glue::WebAccessibility::STATE_CHECKED) |
64 (1 << webkit_glue::WebAccessibility::STATE_FOCUSED);
65 inner1.location = WebKit::WebRect(10, 10, 900, 400);
66 outer.children.push_back(inner1);
67 webkit_glue::WebAccessibility inner2;
68 inner2.id = 1002;
69 inner2.name = ASCIIToUTF16("inner2_name");
70 inner2.role = webkit_glue::WebAccessibility::ROLE_RADIOBUTTON;
71 inner2.state = (1 << webkit_glue::WebAccessibility::STATE_CHECKED);
72 inner2.location = WebKit::WebRect(10, 500, 900, 400);
73 outer.children.push_back(inner2);
74
75 IPC::Message msg2(1, 2, IPC::Message::PRIORITY_NORMAL);
76 IPC::WriteParam(&msg2, outer);
77
78 void* iter2 = NULL;
79 EXPECT_TRUE(IPC::ReadParam(&msg2, &iter2, &output));
80 EXPECT_EQ(outer.id, output.id);
81 EXPECT_EQ(outer.name, output.name);
82 EXPECT_EQ(outer.role, output.role);
83 EXPECT_EQ(outer.state, output.state);
84 EXPECT_EQ(outer.location, output.location);
85 EXPECT_EQ(outer.children.size(), output.children.size());
86 EXPECT_EQ(inner1.id, output.children[0].id);
87 EXPECT_EQ(inner1.name, output.children[0].name);
88 EXPECT_EQ(inner1.role, output.children[0].role);
89 EXPECT_EQ(inner1.state, output.children[0].state);
90 EXPECT_EQ(inner1.location, output.children[0].location);
91 EXPECT_EQ(inner2.id, output.children[1].id);
92 EXPECT_EQ(inner2.name, output.children[1].name);
93 EXPECT_EQ(inner2.role, output.children[1].role);
94 EXPECT_EQ(inner2.state, output.children[1].state);
95 EXPECT_EQ(inner2.location, output.children[1].location);
96 }
OLDNEW
« no previous file with comments | « chrome/common/render_messages_internal.h ('k') | chrome/renderer/render_thread.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698