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

Side by Side Diff: content/browser/frame_host/frame_tree_node_blame_context_unittest.cc

Issue 2228403003: content: Use stl utilities from the base namespace (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 4 years, 4 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "content/browser/frame_host/frame_tree_node_blame_context.h" 5 #include "content/browser/frame_host/frame_tree_node_blame_context.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "base/test/trace_event_analyzer.h" 9 #include "base/test/trace_event_analyzer.h"
10 #include "base/trace_event/trace_buffer.h" 10 #include "base/trace_event/trace_buffer.h"
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 173
174 std::set<FrameTreeNode*> creation_traced; 174 std::set<FrameTreeNode*> creation_traced;
175 std::set<FrameTreeNode*> snapshot_traced; 175 std::set<FrameTreeNode*> snapshot_traced;
176 for (auto* event : events) { 176 for (auto* event : events) {
177 ExpectFrameTreeNodeObject(event); 177 ExpectFrameTreeNodeObject(event);
178 FrameTreeNode* node = 178 FrameTreeNode* node =
179 tree()->FindByID(strtol(event->id.c_str(), nullptr, 16)); 179 tree()->FindByID(strtol(event->id.c_str(), nullptr, 16));
180 EXPECT_NE(nullptr, node); 180 EXPECT_NE(nullptr, node);
181 if (event->HasArg("snapshot")) { 181 if (event->HasArg("snapshot")) {
182 ExpectFrameTreeNodeSnapshot(event); 182 ExpectFrameTreeNodeSnapshot(event);
183 EXPECT_FALSE(ContainsValue(snapshot_traced, node)); 183 EXPECT_FALSE(base::ContainsValue(snapshot_traced, node));
184 snapshot_traced.insert(node); 184 snapshot_traced.insert(node);
185 std::string parent_id = GetParentNodeID(event); 185 std::string parent_id = GetParentNodeID(event);
186 EXPECT_FALSE(parent_id.empty()); 186 EXPECT_FALSE(parent_id.empty());
187 EXPECT_EQ(node->parent(), 187 EXPECT_EQ(node->parent(),
188 tree()->FindByID(strtol(parent_id.c_str(), nullptr, 16))); 188 tree()->FindByID(strtol(parent_id.c_str(), nullptr, 16)));
189 } else { 189 } else {
190 EXPECT_EQ(TRACE_EVENT_PHASE_CREATE_OBJECT, event->phase); 190 EXPECT_EQ(TRACE_EVENT_PHASE_CREATE_OBJECT, event->phase);
191 EXPECT_FALSE(ContainsValue(creation_traced, node)); 191 EXPECT_FALSE(base::ContainsValue(creation_traced, node));
192 creation_traced.insert(node); 192 creation_traced.insert(node);
193 } 193 }
194 } 194 }
195 } 195 }
196 196
197 // Deletes frames from a frame tree, tests if the destruction of each frame is 197 // Deletes frames from a frame tree, tests if the destruction of each frame is
198 // correctly traced. 198 // correctly traced.
199 TEST_F(FrameTreeNodeBlameContextTest, FrameDeletion) { 199 TEST_F(FrameTreeNodeBlameContextTest, FrameDeletion) {
200 /* Shape of the frame tree to be created: 200 /* Shape of the frame tree to be created:
201 * () 201 * ()
(...skipping 20 matching lines...) Expand all
222 trace_analyzer::TraceEventVector events; 222 trace_analyzer::TraceEventVector events;
223 trace_analyzer::Query q = 223 trace_analyzer::Query q =
224 trace_analyzer::Query::EventPhaseIs(TRACE_EVENT_PHASE_DELETE_OBJECT); 224 trace_analyzer::Query::EventPhaseIs(TRACE_EVENT_PHASE_DELETE_OBJECT);
225 analyzer->FindEvents(q, &events); 225 analyzer->FindEvents(q, &events);
226 226
227 // The removal of all non-root nodes should be traced. 227 // The removal of all non-root nodes should be traced.
228 EXPECT_EQ(6u, events.size()); 228 EXPECT_EQ(6u, events.size());
229 for (auto* event : events) { 229 for (auto* event : events) {
230 ExpectFrameTreeNodeObject(event); 230 ExpectFrameTreeNodeObject(event);
231 int id = strtol(event->id.c_str(), nullptr, 16); 231 int id = strtol(event->id.c_str(), nullptr, 16);
232 EXPECT_TRUE(ContainsValue(node_ids, id)); 232 EXPECT_TRUE(base::ContainsValue(node_ids, id));
233 node_ids.erase(id); 233 node_ids.erase(id);
234 } 234 }
235 } 235 }
236 236
237 // Changes URL of the root node. Tests if URL change is correctly traced. 237 // Changes URL of the root node. Tests if URL change is correctly traced.
238 TEST_F(FrameTreeNodeBlameContextTest, URLChange) { 238 TEST_F(FrameTreeNodeBlameContextTest, URLChange) {
239 main_test_rfh()->InitializeRenderFrameIfNeeded(); 239 main_test_rfh()->InitializeRenderFrameIfNeeded();
240 GURL url1("http://a.com/"); 240 GURL url1("http://a.com/");
241 GURL url2("https://b.net/"); 241 GURL url2("https://b.net/");
242 242
(...skipping 12 matching lines...) Expand all
255 std::sort(events.begin(), events.end(), EventPointerCompare); 255 std::sort(events.begin(), events.end(), EventPointerCompare);
256 256
257 // Three snapshots are traced, one for each URL change. 257 // Three snapshots are traced, one for each URL change.
258 EXPECT_EQ(3u, events.size()); 258 EXPECT_EQ(3u, events.size());
259 EXPECT_EQ(url1.spec(), GetSnapshotURL(events[0])); 259 EXPECT_EQ(url1.spec(), GetSnapshotURL(events[0]));
260 EXPECT_EQ(url2.spec(), GetSnapshotURL(events[1])); 260 EXPECT_EQ(url2.spec(), GetSnapshotURL(events[1]));
261 EXPECT_EQ("", GetSnapshotURL(events[2])); 261 EXPECT_EQ("", GetSnapshotURL(events[2]));
262 } 262 }
263 263
264 } // namespace content 264 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/fileapi/copy_or_move_operation_delegate_unittest.cc ('k') | content/browser/host_zoom_map_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698