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

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

Issue 6713084: Move the rest of the renderer->browser messages that belong in content. Also do a bunch of cleanup: (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 9 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_params.cc ('k') | chrome/common/safebrowsing_messages.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/utf_string_conversions.h"
8 #include "chrome/common/render_messages.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "webkit/glue/web_io_operators.h"
11 #include "webkit/glue/webaccessibility.h"
12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRect.h"
13
14 TEST(RenderMessagesUnittest, WebAccessibility) {
15 // Test a simple case.
16 webkit_glue::WebAccessibility input;
17 input.id = 123;
18 input.name = ASCIIToUTF16("name");
19 input.value = ASCIIToUTF16("value");
20 string16 help = ASCIIToUTF16("help");
21 input.attributes[webkit_glue::WebAccessibility::ATTR_HELP] = help;
22 input.role = webkit_glue::WebAccessibility::ROLE_CHECKBOX;
23 input.state =
24 (1 << webkit_glue::WebAccessibility::STATE_CHECKED) |
25 (1 << webkit_glue::WebAccessibility::STATE_FOCUSED);
26 input.location = WebKit::WebRect(11, 22, 333, 444);
27 input.html_attributes.push_back(
28 std::pair<string16, string16>(ASCIIToUTF16("id"), ASCIIToUTF16("a")));
29 input.html_attributes.push_back(
30 std::pair<string16, string16>(ASCIIToUTF16("class"), ASCIIToUTF16("b")));
31
32 IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL);
33 IPC::WriteParam(&msg, input);
34
35 webkit_glue::WebAccessibility output;
36 void* iter = NULL;
37 EXPECT_TRUE(IPC::ReadParam(&msg, &iter, &output));
38 EXPECT_EQ(input.id, output.id);
39 EXPECT_EQ(input.name, output.name);
40 EXPECT_EQ(input.value, output.value);
41 EXPECT_EQ(static_cast<size_t>(1), input.attributes.size());
42 EXPECT_EQ(help, input.attributes[webkit_glue::WebAccessibility::ATTR_HELP]);
43 EXPECT_EQ(input.role, output.role);
44 EXPECT_EQ(input.state, output.state);
45 EXPECT_EQ(input.location, output.location);
46 EXPECT_EQ(input.children.size(), output.children.size());
47 EXPECT_EQ(input.html_attributes.size(), output.html_attributes.size());
48 EXPECT_EQ(input.html_attributes[0].first,
49 output.html_attributes[0].first);
50 EXPECT_EQ(input.html_attributes[0].second,
51 output.html_attributes[0].second);
52 EXPECT_EQ(input.html_attributes[1].first,
53 output.html_attributes[1].first);
54 EXPECT_EQ(input.html_attributes[1].second,
55 output.html_attributes[1].second);
56
57 // Test a corrupt case.
58 IPC::Message bad_msg(1, 2, IPC::Message::PRIORITY_NORMAL);
59 bad_msg.WriteInt(99);
60 iter = NULL;
61 EXPECT_FALSE(IPC::ReadParam(&bad_msg, &iter, &output));
62
63 // Test a recursive case.
64 webkit_glue::WebAccessibility outer;
65 outer.id = 1000;
66 outer.name = ASCIIToUTF16("outer_name");
67 outer.role = webkit_glue::WebAccessibility::ROLE_GROUP;
68 outer.state = 0;
69 outer.location = WebKit::WebRect(0, 0, 1000, 1000);
70 webkit_glue::WebAccessibility inner1;
71 inner1.id = 1001;
72 inner1.name = ASCIIToUTF16("inner1_name");
73 inner1.role = webkit_glue::WebAccessibility::ROLE_RADIO_BUTTON;
74 inner1.state =
75 (1 << webkit_glue::WebAccessibility::STATE_CHECKED) |
76 (1 << webkit_glue::WebAccessibility::STATE_FOCUSED);
77 inner1.location = WebKit::WebRect(10, 10, 900, 400);
78 outer.children.push_back(inner1);
79 webkit_glue::WebAccessibility inner2;
80 inner2.id = 1002;
81 inner2.name = ASCIIToUTF16("inner2_name");
82 inner2.role = webkit_glue::WebAccessibility::ROLE_RADIO_BUTTON;
83 inner2.state = (1 << webkit_glue::WebAccessibility::STATE_CHECKED);
84 inner2.location = WebKit::WebRect(10, 500, 900, 400);
85 outer.children.push_back(inner2);
86
87 IPC::Message msg2(1, 2, IPC::Message::PRIORITY_NORMAL);
88 IPC::WriteParam(&msg2, outer);
89
90 void* iter2 = NULL;
91 EXPECT_TRUE(IPC::ReadParam(&msg2, &iter2, &output));
92 EXPECT_EQ(outer.id, output.id);
93 EXPECT_EQ(outer.name, output.name);
94 EXPECT_EQ(outer.role, output.role);
95 EXPECT_EQ(outer.state, output.state);
96 EXPECT_EQ(outer.location, output.location);
97 EXPECT_EQ(outer.children.size(), output.children.size());
98 EXPECT_EQ(inner1.id, output.children[0].id);
99 EXPECT_EQ(inner1.name, output.children[0].name);
100 EXPECT_EQ(inner1.role, output.children[0].role);
101 EXPECT_EQ(inner1.state, output.children[0].state);
102 EXPECT_EQ(inner1.location, output.children[0].location);
103 EXPECT_EQ(inner2.id, output.children[1].id);
104 EXPECT_EQ(inner2.name, output.children[1].name);
105 EXPECT_EQ(inner2.role, output.children[1].role);
106 EXPECT_EQ(inner2.state, output.children[1].state);
107 EXPECT_EQ(inner2.location, output.children[1].location);
108 }
OLDNEW
« no previous file with comments | « chrome/common/render_messages_params.cc ('k') | chrome/common/safebrowsing_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698