| 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/browser_thread.h" | 13 #include "content/browser/browser_thread.h" |
| 14 #include "content/browser/renderer_host/test_render_view_host.h" | 14 #include "content/browser/renderer_host/test_render_view_host.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 16 | 16 |
| 17 class GURL; | 17 class GURL; |
| 18 class NavigationController; | 18 class NavigationController; |
| 19 | 19 |
| 20 // Base class for browser based unit tests. BrowserWithTestWindowTest creates a | 20 // Base class for browser based unit tests. BrowserWithTestWindowTest creates a |
| 21 // Browser with a TestingProfile and TestBrowserWindow. To add a tab use | 21 // Browser with a TestingProfile and TestBrowserWindow. To add a tab use |
| 22 // AddTestingTab. For example, the following adds a tab and navigates to | 22 // AddTab. For example, the following adds a tab and navigates to |
| 23 // two URLs that target the TestTabContents: | 23 // two URLs that target the TestTabContents: |
| 24 // | 24 // |
| 25 // // Add a new tab and navigate it. This will be at index 0. | 25 // // Add a new tab and navigate it. This will be at index 0. |
| 26 // AddTab(browser(), GURL("http://foo/1")); | 26 // AddTab(browser(), GURL("http://foo/1")); |
| 27 // NavigationController* controller = | 27 // NavigationController* controller = |
| 28 // browser()->GetTabContentsAt(0)->controller(); | 28 // &browser()->GetTabContentsAt(0)->controller(); |
| 29 // | 29 // |
| 30 // // Navigate somewhere else. | 30 // // Navigate somewhere else. |
| 31 // GURL url2("http://foo/2"); | 31 // GURL url2("http://foo/2"); |
| 32 // NavigateAndCommit(controller, url2); | 32 // NavigateAndCommit(controller, url2); |
| 33 // | 33 // |
| 34 // // This is equivalent to the above, and lets you test pending navigations. | 34 // // This is equivalent to the above, and lets you test pending navigations. |
| 35 // browser()->OpenURL(GURL("http://foo/2"), GURL(), CURRENT_TAB, | 35 // browser()->OpenURL(GURL("http://foo/2"), GURL(), CURRENT_TAB, |
| 36 // PageTransition::TYPED); | 36 // PageTransition::TYPED); |
| 37 // CommitPendingLoadAsNewNavigation(controller, url2); | 37 // CommitPendingLoad(controller); |
| 38 // | 38 // |
| 39 // Subclasses must invoke BrowserWithTestWindowTest::SetUp as it is responsible | 39 // Subclasses must invoke BrowserWithTestWindowTest::SetUp as it is responsible |
| 40 // for creating the various objects of this class. | 40 // for creating the various objects of this class. |
| 41 class BrowserWithTestWindowTest : public testing::Test { | 41 class BrowserWithTestWindowTest : public testing::Test { |
| 42 public: | 42 public: |
| 43 BrowserWithTestWindowTest(); | 43 BrowserWithTestWindowTest(); |
| 44 virtual ~BrowserWithTestWindowTest(); | 44 virtual ~BrowserWithTestWindowTest(); |
| 45 | 45 |
| 46 virtual void SetUp(); | 46 virtual void SetUp(); |
| 47 | 47 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 scoped_ptr<TestBrowserWindow> window_; | 103 scoped_ptr<TestBrowserWindow> window_; |
| 104 scoped_ptr<Browser> browser_; | 104 scoped_ptr<Browser> browser_; |
| 105 | 105 |
| 106 MockRenderProcessHostFactory rph_factory_; | 106 MockRenderProcessHostFactory rph_factory_; |
| 107 TestRenderViewHostFactory rvh_factory_; | 107 TestRenderViewHostFactory rvh_factory_; |
| 108 | 108 |
| 109 DISALLOW_COPY_AND_ASSIGN(BrowserWithTestWindowTest); | 109 DISALLOW_COPY_AND_ASSIGN(BrowserWithTestWindowTest); |
| 110 }; | 110 }; |
| 111 | 111 |
| 112 #endif // CHROME_TEST_BASE_BROWSER_WITH_TEST_WINDOW_TEST_H_ | 112 #endif // CHROME_TEST_BASE_BROWSER_WITH_TEST_WINDOW_TEST_H_ |
| OLD | NEW |