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
3 // found in the LICENSE file.
5 #ifndef CONTENT_TEST_CONTENT_BROWSER_TEST_UTILS_INTERNAL_H_
6 #define CONTENT_TEST_CONTENT_BROWSER_TEST_UTILS_INTERNAL_H_
8 // A collection of functions designed for use with content_shell based browser
9 // tests internal to the content/ module.
10 // Note: If a function here also works with browser_tests, it should be in
11 // the content public API.
16 #include "base/basictypes.h"
25 // Navigates the frame represented by |node| to |url|, blocking until the
26 // navigation finishes.
27 void NavigateFrameToURL(FrameTreeNode
* node
, const GURL
& url
);
29 // Creates compact textual representations of the state of the frame tree that
30 // is appropriate for use in assertions.
32 // The diagrams show frame tree structure, the SiteInstance of current frames,
33 // presence of pending frames, and the SiteInstances of any and all proxies.
34 // They look like this:
36 // Site A (D pending) -- proxies for B C
37 // |--Site B --------- proxies for A C
38 // +--Site C --------- proxies for B A
39 // |--Site A ---- proxies for B
40 // +--Site A ---- proxies for B
41 // +--Site A -- proxies for B
42 // Where A = http://127.0.0.1/
43 // B = http://foo.com/ (no process)
44 // C = http://bar.com/
45 // D = http://next.com/
47 // SiteInstances are assigned single-letter names (A, B, C) which are remembered
48 // across invocations of the pretty-printer.
49 class FrameTreeVisualizer
{
51 FrameTreeVisualizer();
52 ~FrameTreeVisualizer();
54 // Formats and returns a diagram for the provided FrameTreeNode.
55 std::string
DepictFrameTree(FrameTreeNode
* root
);
58 // Assign or retrive the abbreviated short name (A, B, C) for a site instance.
59 std::string
GetName(SiteInstance
* site_instance
);
61 // Elements are site instance ids. The index of the SiteInstance in the vector
62 // determines the abbreviated name (0->A, 1->B) for that SiteInstance.
63 std::vector
<int> seen_site_instance_ids_
;
65 DISALLOW_COPY_AND_ASSIGN(FrameTreeVisualizer
);
68 } // namespace content
70 #endif // CONTENT_TEST_CONTENT_BROWSER_TEST_UTILS_INTERNAL_H_