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

Side by Side Diff: content/test/web_contents_tester.cc

Issue 9706012: Add abstractions that let embedders drive tests of WebContents. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove CONTENT_EXPORT on statically linked functions. Merge to head for commit. Created 8 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 | « content/test/web_contents_tester.h ('k') | no next file » | 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) 2012 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 "content/test/web_contents_tester.h"
6
7 #include "content/browser/tab_contents/test_tab_contents.h"
8
9 namespace content {
10
11 namespace {
12
13 // The two subclasses here are instantiated via the deprecated
14 // CreateWebContentsFor... factories below.
15
16 class TestTabContentsCountFocus : public TestTabContents {
17 public:
18 TestTabContentsCountFocus(content::BrowserContext* browser_context,
19 content::SiteInstance* instance)
20 : TestTabContents(browser_context, instance), focus_called_(0) {
21 }
22
23 virtual int GetNumberOfFocusCalls() OVERRIDE {
24 return focus_called_;
25 }
26
27 virtual void Focus() OVERRIDE {
28 focus_called_++;
29 }
30
31 private:
32 int focus_called_;
33 };
34
35 class TestTabContentsCountSetFocusToLocationBar : public TestTabContents {
36 public:
37 TestTabContentsCountSetFocusToLocationBar(
38 content::BrowserContext* browser_context,
39 SiteInstance* instance)
40 : TestTabContents(browser_context, instance), focus_called_(0) {
41 }
42
43 virtual void SetFocusToLocationBar(bool select_all) { ++focus_called_; }
44 virtual int GetNumberOfFocusCalls() OVERRIDE {
45 return focus_called_;
46 }
47
48 private:
49 int focus_called_;
50 };
51
52 } // namespace
53
54 // static
55 WebContentsTester* WebContentsTester::For(WebContents* contents) {
56 return static_cast<TestTabContents*>(contents);
57 }
58
59 // static
60 WebContents* WebContentsTester::CreateTestWebContents(
61 BrowserContext* browser_context,
62 SiteInstance* instance) {
63 return new TestTabContents(browser_context, instance);
64 }
65
66 // static
67 WebContents* WebContentsTester::CreateTestWebContentsCountSetFocusToLocationBar(
68 BrowserContext* browser_context,
69 SiteInstance* instance) {
70 return new TestTabContentsCountSetFocusToLocationBar(
71 browser_context, instance);
72 }
73
74 // static
75 WebContents* WebContentsTester::CreateTestWebContentsCountFocus(
76 BrowserContext* browser_context,
77 SiteInstance* instance) {
78 return new TestTabContentsCountFocus(browser_context, instance);
79 }
80
81 } // namespace content
OLDNEW
« no previous file with comments | « content/test/web_contents_tester.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698