OLD | NEW |
(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 |
OLD | NEW |