| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef CHROME_TEST_BASE_BROWSER_WITH_TEST_WINDOW_TEST_H_ | 5 #ifndef CHROME_TEST_BASE_BROWSER_WITH_TEST_WINDOW_TEST_H_ |
| 6 #define CHROME_TEST_BASE_BROWSER_WITH_TEST_WINDOW_TEST_H_ | 6 #define CHROME_TEST_BASE_BROWSER_WITH_TEST_WINDOW_TEST_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
| 11 #include "chrome/test/base/test_browser_window.h" | 11 #include "chrome/test/base/test_browser_window.h" |
| 12 #include "chrome/test/base/testing_profile.h" | 12 #include "chrome/test/base/testing_profile.h" |
| 13 #include "content/browser/renderer_host/test_render_view_host.h" | 13 #include "content/browser/renderer_host/test_render_view_host.h" |
| 14 #include "content/test/test_browser_thread.h" | 14 #include "content/test/test_browser_thread.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 16 | 16 |
| 17 #if defined(USE_AURA) | 17 #if defined(USE_AURA) |
| 18 #include "ui/aura/test/test_activation_client.h" | 18 #include "ui/aura/test/test_activation_client.h" |
| 19 #endif | 19 #endif |
| 20 | 20 |
| 21 class GURL; | 21 class GURL; |
| 22 class NavigationController; | |
| 23 | 22 |
| 24 #if defined(USE_AURA) | 23 #if defined(USE_AURA) |
| 25 namespace aura { | 24 namespace aura { |
| 26 namespace test { | 25 namespace test { |
| 27 class TestActivationClient; | 26 class TestActivationClient; |
| 28 } | 27 } |
| 29 } | 28 } |
| 30 #endif | 29 #endif |
| 31 | 30 |
| 32 namespace content { | 31 namespace content { |
| 32 class NavigationController; |
| 33 class WebContents; | 33 class WebContents; |
| 34 } | 34 } |
| 35 | 35 |
| 36 // Base class for browser based unit tests. BrowserWithTestWindowTest creates a | 36 // Base class for browser based unit tests. BrowserWithTestWindowTest creates a |
| 37 // Browser with a TestingProfile and TestBrowserWindow. To add a tab use | 37 // Browser with a TestingProfile and TestBrowserWindow. To add a tab use |
| 38 // AddTab. For example, the following adds a tab and navigates to | 38 // AddTab. For example, the following adds a tab and navigates to |
| 39 // two URLs that target the TestTabContents: | 39 // two URLs that target the TestTabContents: |
| 40 // | 40 // |
| 41 // // Add a new tab and navigate it. This will be at index 0. | 41 // // Add a new tab and navigate it. This will be at index 0. |
| 42 // AddTab(browser(), GURL("http://foo/1")); | 42 // AddTab(browser(), GURL("http://foo/1")); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 } | 84 } |
| 85 | 85 |
| 86 MessageLoop* message_loop() { return &ui_loop_; } | 86 MessageLoop* message_loop() { return &ui_loop_; } |
| 87 | 87 |
| 88 // Adds a tab to |browser| with the given URL and commits the load. | 88 // Adds a tab to |browser| with the given URL and commits the load. |
| 89 // This is a convenience function. The new tab will be added at index 0. | 89 // This is a convenience function. The new tab will be added at index 0. |
| 90 void AddTab(Browser* browser, const GURL& url); | 90 void AddTab(Browser* browser, const GURL& url); |
| 91 | 91 |
| 92 // Commits the pending load on the given controller. It will keep the | 92 // Commits the pending load on the given controller. It will keep the |
| 93 // URL of the pending load. If there is no pending load, this does nothing. | 93 // URL of the pending load. If there is no pending load, this does nothing. |
| 94 void CommitPendingLoad(NavigationController* controller); | 94 void CommitPendingLoad(content::NavigationController* controller); |
| 95 | 95 |
| 96 // Creates a pending navigation on the given navigation controller to the | 96 // Creates a pending navigation on the given navigation controller to the |
| 97 // given URL with the default parameters and the commits the load with a page | 97 // given URL with the default parameters and the commits the load with a page |
| 98 // ID one larger than any seen. This emulates what happens on a new | 98 // ID one larger than any seen. This emulates what happens on a new |
| 99 // navigation. | 99 // navigation. |
| 100 void NavigateAndCommit(NavigationController* controller, | 100 void NavigateAndCommit(content::NavigationController* controller, |
| 101 const GURL& url); | 101 const GURL& url); |
| 102 | 102 |
| 103 // Navigates the current tab. This is a wrapper around NavigateAndCommit. | 103 // Navigates the current tab. This is a wrapper around NavigateAndCommit. |
| 104 void NavigateAndCommitActiveTab(const GURL& url); | 104 void NavigateAndCommitActiveTab(const GURL& url); |
| 105 | 105 |
| 106 protected: | 106 protected: |
| 107 // Destroys the browser and window created by this class. This is invoked from | 107 // Destroys the browser and window created by this class. This is invoked from |
| 108 // the destructor. | 108 // the destructor. |
| 109 void DestroyBrowser(); | 109 void DestroyBrowser(); |
| 110 | 110 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 125 TestRenderViewHostFactory rvh_factory_; | 125 TestRenderViewHostFactory rvh_factory_; |
| 126 | 126 |
| 127 #if defined(USE_AURA) | 127 #if defined(USE_AURA) |
| 128 scoped_ptr<aura::test::TestActivationClient> test_activation_client_; | 128 scoped_ptr<aura::test::TestActivationClient> test_activation_client_; |
| 129 #endif | 129 #endif |
| 130 | 130 |
| 131 DISALLOW_COPY_AND_ASSIGN(BrowserWithTestWindowTest); | 131 DISALLOW_COPY_AND_ASSIGN(BrowserWithTestWindowTest); |
| 132 }; | 132 }; |
| 133 | 133 |
| 134 #endif // CHROME_TEST_BASE_BROWSER_WITH_TEST_WINDOW_TEST_H_ | 134 #endif // CHROME_TEST_BASE_BROWSER_WITH_TEST_WINDOW_TEST_H_ |
| OLD | NEW |