Content settings: remove some plugin-related code/resources when... there are no...
[chromium-blink-merge.git] / content / test / content_browser_test_utils_internal.h
blob05544b8a79c99a4e24c55fee7a7afe42db9fb7ac
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.
13 #include <string>
14 #include <vector>
16 #include "base/basictypes.h"
18 class GURL;
20 namespace content {
22 class FrameTreeNode;
23 class Shell;
24 class SiteInstance;
25 class ToRenderFrameHost;
27 // Navigates the frame represented by |node| to |url|, blocking until the
28 // navigation finishes.
29 void NavigateFrameToURL(FrameTreeNode* node, const GURL& url);
31 // Creates compact textual representations of the state of the frame tree that
32 // is appropriate for use in assertions.
34 // The diagrams show frame tree structure, the SiteInstance of current frames,
35 // presence of pending frames, and the SiteInstances of any and all proxies.
36 // They look like this:
38 // Site A (D pending) -- proxies for B C
39 // |--Site B --------- proxies for A C
40 // +--Site C --------- proxies for B A
41 // |--Site A ---- proxies for B
42 // +--Site A ---- proxies for B
43 // +--Site A -- proxies for B
44 // Where A = http://127.0.0.1/
45 // B = http://foo.com/ (no process)
46 // C = http://bar.com/
47 // D = http://next.com/
49 // SiteInstances are assigned single-letter names (A, B, C) which are remembered
50 // across invocations of the pretty-printer.
51 class FrameTreeVisualizer {
52 public:
53 FrameTreeVisualizer();
54 ~FrameTreeVisualizer();
56 // Formats and returns a diagram for the provided FrameTreeNode.
57 std::string DepictFrameTree(FrameTreeNode* root);
59 private:
60 // Assign or retrive the abbreviated short name (A, B, C) for a site instance.
61 std::string GetName(SiteInstance* site_instance);
63 // Elements are site instance ids. The index of the SiteInstance in the vector
64 // determines the abbreviated name (0->A, 1->B) for that SiteInstance.
65 std::vector<int> seen_site_instance_ids_;
67 DISALLOW_COPY_AND_ASSIGN(FrameTreeVisualizer);
70 // Uses window.open to open a popup from the frame |opener| with the specified
71 // |url| and |name|. Waits for the navigation to |url| to finish and then
72 // returns the new popup's Shell. Note that since this navigation to |url| is
73 // renderer-initiated, it won't cause a process swap unless used in
74 // --site-per-process mode.
75 Shell* OpenPopup(const ToRenderFrameHost& opener,
76 const GURL& url,
77 const std::string& name);
79 } // namespace content
81 #endif // CONTENT_TEST_CONTENT_BROWSER_TEST_UTILS_INTERNAL_H_