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

Side by Side Diff: components/html_viewer/ax_provider_impl_unittest.cc

Issue 1548113002: Switch to standard integer types in components/, part 2 of 4. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: gn Created 4 years, 12 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/html_viewer/ax_provider_impl.h" 5 #include "components/html_viewer/ax_provider_impl.h"
6 6
7 #include <stddef.h>
8 #include <stdint.h>
9
7 #include "base/bind.h" 10 #include "base/bind.h"
8 #include "base/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
9 #include "components/html_viewer/blink_platform_impl.h" 12 #include "components/html_viewer/blink_platform_impl.h"
10 #include "components/scheduler/renderer/renderer_scheduler.h" 13 #include "components/scheduler/renderer/renderer_scheduler.h"
11 #include "gin/v8_initializer.h" 14 #include "gin/v8_initializer.h"
12 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
13 #include "third_party/WebKit/public/platform/WebData.h" 16 #include "third_party/WebKit/public/platform/WebData.h"
14 #include "third_party/WebKit/public/platform/WebURL.h" 17 #include "third_party/WebKit/public/platform/WebURL.h"
15 #include "third_party/WebKit/public/web/WebFrameClient.h" 18 #include "third_party/WebKit/public/web/WebFrameClient.h"
16 #include "third_party/WebKit/public/web/WebKit.h" 19 #include "third_party/WebKit/public/web/WebKit.h"
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 WebURL(GURL("http://someplace.net"))); 117 WebURL(GURL("http://someplace.net")));
115 base::MessageLoop::current()->Run(); 118 base::MessageLoop::current()->Run();
116 119
117 mojo::AxProviderPtr service_ptr; 120 mojo::AxProviderPtr service_ptr;
118 html_viewer::AxProviderImpl ax_provider_impl(view, 121 html_viewer::AxProviderImpl ax_provider_impl(view,
119 mojo::GetProxy(&service_ptr)); 122 mojo::GetProxy(&service_ptr));
120 NodeCatcher catcher; 123 NodeCatcher catcher;
121 ax_provider_impl.GetTree( 124 ax_provider_impl.GetTree(
122 base::Bind(&NodeCatcher::OnNodes, base::Unretained(&catcher))); 125 base::Bind(&NodeCatcher::OnNodes, base::Unretained(&catcher)));
123 126
124 std::map<uint32, AxNode*> lookup; 127 std::map<uint32_t, AxNode*> lookup;
125 for (size_t i = 0; i < catcher.nodes.size(); ++i) { 128 for (size_t i = 0; i < catcher.nodes.size(); ++i) {
126 auto& node = catcher.nodes[i]; 129 auto& node = catcher.nodes[i];
127 lookup[node->id] = node.get(); 130 lookup[node->id] = node.get();
128 } 131 }
129 132
130 typedef decltype(lookup)::value_type MapEntry; 133 typedef decltype(lookup)::value_type MapEntry;
131 auto is_link = [](MapEntry pair) { return !pair.second->link.is_null(); }; 134 auto is_link = [](MapEntry pair) { return !pair.second->link.is_null(); };
132 auto is_text = [](MapEntry pair, const char* content) { 135 auto is_text = [](MapEntry pair, const char* content) {
133 return !pair.second->text.is_null() && 136 return !pair.second->text.is_null() &&
134 pair.second->text->content.To<std::string>() == content; 137 pair.second->text->content.To<std::string>() == content;
(...skipping 22 matching lines...) Expand all
157 ->Equals(*bar)); 160 ->Equals(*bar));
158 EXPECT_TRUE(CreateNode(baz->id, baz->parent_id, 0, baz->bounds, "", "baz") 161 EXPECT_TRUE(CreateNode(baz->id, baz->parent_id, 0, baz->bounds, "", "baz")
159 ->Equals(*baz)); 162 ->Equals(*baz));
160 EXPECT_TRUE(CreateNode(link->id, 163 EXPECT_TRUE(CreateNode(link->id,
161 link->parent_id, 164 link->parent_id,
162 link->next_sibling_id, 165 link->next_sibling_id,
163 link->bounds, 166 link->bounds,
164 "http://monkey.net/", 167 "http://monkey.net/",
165 "")->Equals(*link)); 168 "")->Equals(*link));
166 169
167 auto is_descendant_of = [&lookup](uint32 id, uint32 ancestor) { 170 auto is_descendant_of = [&lookup](uint32_t id, uint32_t ancestor) {
168 for (; (id = lookup[id]->parent_id) != 0;) { 171 for (; (id = lookup[id]->parent_id) != 0;) {
169 if (id == ancestor) 172 if (id == ancestor)
170 return true; 173 return true;
171 } 174 }
172 return false; 175 return false;
173 }; 176 };
174 177
175 EXPECT_TRUE(is_descendant_of(bar->id, link->id)); 178 EXPECT_TRUE(is_descendant_of(bar->id, link->id));
176 for (auto pair : lookup) { 179 for (auto pair : lookup) {
177 AxNode* node = pair.second; 180 AxNode* node = pair.second;
178 if (node != root) 181 if (node != root)
179 EXPECT_TRUE(is_descendant_of(node->id, 1u)); 182 EXPECT_TRUE(is_descendant_of(node->id, 1u));
180 if (node != link && node != foo && node != bar && node != baz) { 183 if (node != link && node != foo && node != bar && node != baz) {
181 EXPECT_TRUE(CreateNode(node->id, 184 EXPECT_TRUE(CreateNode(node->id,
182 node->parent_id, 185 node->parent_id,
183 node->next_sibling_id, 186 node->next_sibling_id,
184 node->bounds, 187 node->bounds,
185 "", 188 "",
186 "")); 189 ""));
187 } 190 }
188 } 191 }
189 192
190 // TODO(aa): Test bounds. 193 // TODO(aa): Test bounds.
191 // TODO(aa): Test sibling ordering of foo/bar/baz. 194 // TODO(aa): Test sibling ordering of foo/bar/baz.
192 195
193 view->close(); 196 view->close();
194 } 197 }
OLDNEW
« no previous file with comments | « components/html_viewer/ax_provider_impl.h ('k') | components/html_viewer/blink_basic_type_converters.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698