OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 #include "chrome/browser/ui/tab_contents/test_tab_contents.h" | 5 #include "chrome/browser/ui/tab_contents/test_tab_contents.h" |
6 | 6 |
7 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 7 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
8 #include "chrome/test/base/testing_profile.h" | 8 #include "chrome/test/base/testing_profile.h" |
9 #include "content/public/browser/web_contents.h" | 9 #include "content/public/browser/web_contents.h" |
10 | 10 |
11 using content::WebContents; | 11 using content::WebContents; |
12 | 12 |
13 TabContentsTestHarness::TabContentsTestHarness() | 13 TabContentsTestHarness::TabContentsTestHarness() |
14 : ChromeRenderViewHostTestHarness() { | 14 : ChromeRenderViewHostTestHarness() { |
15 } | 15 } |
16 | 16 |
17 TabContentsTestHarness::~TabContentsTestHarness() { | 17 TabContentsTestHarness::~TabContentsTestHarness() { |
18 } | 18 } |
19 | 19 |
20 WebContents* TabContentsTestHarness::web_contents() { | 20 WebContents* TabContentsTestHarness::web_contents() { |
21 return tab_contents_.get() ? tab_contents_->web_contents() : NULL; | 21 return tab_contents_.get() ? tab_contents_->web_contents() : NULL; |
22 } | 22 } |
23 | 23 |
24 TabContents* TabContentsTestHarness::tab_contents() { | 24 TabContents* TabContentsTestHarness::tab_contents() { |
25 return tab_contents_.get(); | 25 return tab_contents_.get(); |
26 } | 26 } |
27 | 27 |
28 void TabContentsTestHarness::SetContents(WebContents* contents) { | 28 void TabContentsTestHarness::SetContents(WebContents* contents) { |
29 tab_contents_.reset(contents ? new TabContents(contents) : NULL); | 29 tab_contents_.reset( |
| 30 contents ? TabContents::Factory::CreateTabContents(contents) : NULL); |
30 } | 31 } |
31 | 32 |
32 void TabContentsTestHarness::SetUp() { | 33 void TabContentsTestHarness::SetUp() { |
33 ChromeRenderViewHostTestHarness::SetUp(); | 34 ChromeRenderViewHostTestHarness::SetUp(); |
34 SetContents(CreateTestWebContents()); | 35 SetContents(CreateTestWebContents()); |
35 } | 36 } |
36 | 37 |
37 void TabContentsTestHarness::TearDown() { | 38 void TabContentsTestHarness::TearDown() { |
38 tab_contents_.reset(); | 39 tab_contents_.reset(); |
39 | 40 |
40 // Make sure that we flush any messages related to WebContents destruction | 41 // Make sure that we flush any messages related to WebContents destruction |
41 // before we destroy the browser context. | 42 // before we destroy the browser context. |
42 MessageLoop::current()->RunAllPending(); | 43 MessageLoop::current()->RunAllPending(); |
43 | 44 |
44 // Release the browser context on the UI thread. | 45 // Release the browser context on the UI thread. |
45 message_loop_.DeleteSoon(FROM_HERE, browser_context_.release()); | 46 message_loop_.DeleteSoon(FROM_HERE, browser_context_.release()); |
46 message_loop_.RunAllPending(); | 47 message_loop_.RunAllPending(); |
47 | 48 |
48 ChromeRenderViewHostTestHarness::TearDown(); | 49 ChromeRenderViewHostTestHarness::TearDown(); |
49 } | 50 } |
OLD | NEW |