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

Side by Side Diff: trunk/src/chrome/test/base/browser_with_test_window_test.cc

Issue 213033002: Revert 259580 "Move wm/public into wm target" (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 8 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
OLDNEW
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/test/base/browser_with_test_window_test.h" 5 #include "chrome/test/base/browser_with_test_window_test.h"
6 6
7 #include "base/run_loop.h" 7 #include "base/run_loop.h"
8 #include "chrome/browser/profiles/profile_destroyer.h" 8 #include "chrome/browser/profiles/profile_destroyer.h"
9 #include "chrome/browser/ui/browser.h" 9 #include "chrome/browser/ui/browser.h"
10 #include "chrome/browser/ui/browser_navigator.h" 10 #include "chrome/browser/ui/browser_navigator.h"
11 #include "chrome/browser/ui/tabs/tab_strip_model.h" 11 #include "chrome/browser/ui/tabs/tab_strip_model.h"
12 #include "chrome/common/render_messages.h" 12 #include "chrome/common/render_messages.h"
13 #include "chrome/test/base/testing_profile.h" 13 #include "chrome/test/base/testing_profile.h"
14 #include "content/public/browser/navigation_controller.h" 14 #include "content/public/browser/navigation_controller.h"
15 #include "content/public/browser/navigation_entry.h" 15 #include "content/public/browser/navigation_entry.h"
16 #include "content/public/browser/web_contents.h" 16 #include "content/public/browser/web_contents.h"
17 #include "content/public/common/page_transition_types.h" 17 #include "content/public/common/page_transition_types.h"
18 #include "content/public/test/test_renderer_host.h" 18 #include "content/public/test/test_renderer_host.h"
19 19
20 #if defined(USE_AURA) 20 #if defined(USE_AURA)
21 #include "ui/aura/test/aura_test_helper.h"
21 #include "ui/compositor/test/context_factories_for_test.h" 22 #include "ui/compositor/test/context_factories_for_test.h"
22 #include "ui/wm/test/wm_test_helper.h"
23 #endif 23 #endif
24 24
25 #if defined(USE_ASH) 25 #if defined(USE_ASH)
26 #include "ash/test/ash_test_helper.h" 26 #include "ash/test/ash_test_helper.h"
27 #endif 27 #endif
28 28
29 #if defined(TOOLKIT_VIEWS) 29 #if defined(TOOLKIT_VIEWS)
30 #include "ui/views/test/test_views_delegate.h" 30 #include "ui/views/test/test_views_delegate.h"
31 #endif 31 #endif
32 32
(...skipping 17 matching lines...) Expand all
50 hosted_app_(hosted_app) { 50 hosted_app_(hosted_app) {
51 } 51 }
52 52
53 BrowserWithTestWindowTest::~BrowserWithTestWindowTest() { 53 BrowserWithTestWindowTest::~BrowserWithTestWindowTest() {
54 } 54 }
55 55
56 void BrowserWithTestWindowTest::SetUp() { 56 void BrowserWithTestWindowTest::SetUp() {
57 testing::Test::SetUp(); 57 testing::Test::SetUp();
58 #if defined(OS_CHROMEOS) 58 #if defined(OS_CHROMEOS)
59 // TODO(jamescook): Windows Ash support. This will require refactoring 59 // TODO(jamescook): Windows Ash support. This will require refactoring
60 // AshTestHelper and WMTestHelper so they can be used at the same time, 60 // AshTestHelper and AuraTestHelper so they can be used at the same time,
61 // perhaps by AshTestHelper owning an AuraTestHelper. 61 // perhaps by AshTestHelper owning an AuraTestHelper.
62 ash_test_helper_.reset(new ash::test::AshTestHelper( 62 ash_test_helper_.reset(new ash::test::AshTestHelper(
63 base::MessageLoopForUI::current())); 63 base::MessageLoopForUI::current()));
64 ash_test_helper_->SetUp(true); 64 ash_test_helper_->SetUp(true);
65 #elif defined(USE_AURA) 65 #elif defined(USE_AURA)
66 // The ContextFactory must exist before any Compositors are created. 66 // The ContextFactory must exist before any Compositors are created.
67 bool enable_pixel_output = false; 67 bool enable_pixel_output = false;
68 ui::InitializeContextFactoryForTests(enable_pixel_output); 68 ui::InitializeContextFactoryForTests(enable_pixel_output);
69 69
70 wm_test_helper_.reset(new wm::WMTestHelper); 70 aura_test_helper_.reset(new aura::test::AuraTestHelper(
71 wm_test_helper_->SetUp(); 71 base::MessageLoopForUI::current()));
72 aura_test_helper_->SetUp();
72 #endif // USE_AURA 73 #endif // USE_AURA
73 #if defined(TOOLKIT_VIEWS) 74 #if defined(TOOLKIT_VIEWS)
74 views_delegate_.reset(CreateViewsDelegate()); 75 views_delegate_.reset(CreateViewsDelegate());
75 views::ViewsDelegate::views_delegate = views_delegate_.get(); 76 views::ViewsDelegate::views_delegate = views_delegate_.get();
76 #endif 77 #endif
77 78
78 // Subclasses can provide their own Profile. 79 // Subclasses can provide their own Profile.
79 profile_ = CreateProfile(); 80 profile_ = CreateProfile();
80 // Subclasses can provide their own test BrowserWindow. If they return NULL 81 // Subclasses can provide their own test BrowserWindow. If they return NULL
81 // then Browser will create the a production BrowserWindow and the subclass 82 // then Browser will create the a production BrowserWindow and the subclass
82 // is responsible for cleaning it up (usually by NativeWidget destruction). 83 // is responsible for cleaning it up (usually by NativeWidget destruction).
83 window_.reset(CreateBrowserWindow()); 84 window_.reset(CreateBrowserWindow());
84 85
85 browser_.reset(CreateBrowser(profile(), browser_type_, hosted_app_, 86 browser_.reset(CreateBrowser(profile(), browser_type_, hosted_app_,
86 host_desktop_type_, window_.get())); 87 host_desktop_type_, window_.get()));
87 } 88 }
88 89
89 void BrowserWithTestWindowTest::TearDown() { 90 void BrowserWithTestWindowTest::TearDown() {
90 // Some tests end up posting tasks to the DB thread that must be completed 91 // Some tests end up posting tasks to the DB thread that must be completed
91 // before the profile can be destroyed and the test safely shut down. 92 // before the profile can be destroyed and the test safely shut down.
92 base::RunLoop().RunUntilIdle(); 93 base::RunLoop().RunUntilIdle();
93 94
94 // Reset the profile here because some profile keyed services (like the 95 // Reset the profile here because some profile keyed services (like the
95 // audio service) depend on test stubs that the helpers below will remove. 96 // audio service) depend on test stubs that the helpers below will remove.
96 DestroyBrowserAndProfile(); 97 DestroyBrowserAndProfile();
97 98
98 #if defined(OS_CHROMEOS) 99 #if defined(OS_CHROMEOS)
99 ash_test_helper_->TearDown(); 100 ash_test_helper_->TearDown();
100 #elif defined(USE_AURA) 101 #elif defined(USE_AURA)
101 wm_test_helper_->TearDown(); 102 aura_test_helper_->TearDown();
102 ui::TerminateContextFactoryForTests(); 103 ui::TerminateContextFactoryForTests();
103 #endif 104 #endif
104 testing::Test::TearDown(); 105 testing::Test::TearDown();
105 106
106 // A Task is leaked if we don't destroy everything, then run the message 107 // A Task is leaked if we don't destroy everything, then run the message
107 // loop. 108 // loop.
108 base::MessageLoop::current()->PostTask(FROM_HERE, 109 base::MessageLoop::current()->PostTask(FROM_HERE,
109 base::MessageLoop::QuitClosure()); 110 base::MessageLoop::QuitClosure());
110 base::MessageLoop::current()->Run(); 111 base::MessageLoop::current()->Run();
111 112
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 if (hosted_app) 231 if (hosted_app)
231 params.app_name = "Test"; 232 params.app_name = "Test";
232 return new Browser(params); 233 return new Browser(params);
233 } 234 }
234 235
235 #if defined(TOOLKIT_VIEWS) 236 #if defined(TOOLKIT_VIEWS)
236 views::ViewsDelegate* BrowserWithTestWindowTest::CreateViewsDelegate() { 237 views::ViewsDelegate* BrowserWithTestWindowTest::CreateViewsDelegate() {
237 return new views::TestViewsDelegate; 238 return new views::TestViewsDelegate;
238 } 239 }
239 #endif 240 #endif
OLDNEW
« no previous file with comments | « trunk/src/chrome/test/base/browser_with_test_window_test.h ('k') | trunk/src/chrome/test/base/view_event_test_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698