summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ash/accelerators/accelerator_interactive_uitest_chromeos.cc3
-rw-r--r--ash/drag_drop/drag_drop_interactive_uitest.cc7
-rw-r--r--ash/shell.cc2
-rw-r--r--ash/test/ash_test_helper.cc2
-rw-r--r--ash/test/test_suite.cc3
-rw-r--r--ash/wm/ash_native_cursor_manager_interactive_uitest.cc7
-rw-r--r--chrome/browser/browser_process_impl.cc10
-rw-r--r--chrome/browser/chromeos/policy/status_uploader_unittest.cc17
-rw-r--r--chrome/browser/extensions/test_extension_environment.cc10
-rw-r--r--chrome/browser/ui/views/bookmarks/bookmark_context_menu_unittest.cc3
-rw-r--r--chrome/test/base/chrome_render_view_host_test_harness.cc8
-rw-r--r--chrome/test/base/view_event_test_platform_part_chromeos.cc6
-rw-r--r--content/browser/browser_main_loop.cc4
-rw-r--r--content/browser/renderer_host/render_widget_host_unittest.cc3
-rw-r--r--content/browser/web_contents/web_contents_view_aura.cc2
-rw-r--r--content/public/test/test_web_contents_factory.h3
-rw-r--r--content/public/test/unittest_test_suite.cc22
-rw-r--r--content/test/test_web_contents_factory.cc17
-rw-r--r--ui/aura/test/aura_test_helper.cc11
-rw-r--r--ui/aura/test/aura_test_helper.h1
20 files changed, 61 insertions, 80 deletions
diff --git a/ash/accelerators/accelerator_interactive_uitest_chromeos.cc b/ash/accelerators/accelerator_interactive_uitest_chromeos.cc
index a776229..3babbc5 100644
--- a/ash/accelerators/accelerator_interactive_uitest_chromeos.cc
+++ b/ash/accelerators/accelerator_interactive_uitest_chromeos.cc
@@ -17,6 +17,7 @@
#include "base/path_service.h"
#include "base/run_loop.h"
#include "chromeos/network/network_handler.h"
+#include "ui/aura/env.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/test/ui_controls.h"
#include "ui/base/ui_base_paths.h"
@@ -69,6 +70,7 @@ class AcceleratorInteractiveUITest : public AshTestBase, public ShellObserver {
resources_pack_path.Append(FILE_PATH_LITERAL("resources.pak"));
ResourceBundle::GetSharedInstance().AddDataPackFromPath(
resources_pack_path, ui::SCALE_FACTOR_NONE);
+ aura::Env::CreateInstance(true);
AshTestBase::SetUp();
@@ -83,6 +85,7 @@ class AcceleratorInteractiveUITest : public AshTestBase, public ShellObserver {
Shell::GetInstance()->RemoveShellObserver(this);
AshTestBase::TearDown();
+ aura::Env::DeleteInstance();
}
// Sends a key press event and waits synchronously until it's completely
diff --git a/ash/drag_drop/drag_drop_interactive_uitest.cc b/ash/drag_drop/drag_drop_interactive_uitest.cc
index b8968dcd..91d34ac 100644
--- a/ash/drag_drop/drag_drop_interactive_uitest.cc
+++ b/ash/drag_drop/drag_drop_interactive_uitest.cc
@@ -10,6 +10,7 @@
#include "base/message_loop/message_loop.h"
#include "base/path_service.h"
#include "base/strings/utf_string_conversions.h"
+#include "ui/aura/env.h"
#include "ui/aura/window_event_dispatcher.h"
#include "ui/base/dragdrop/drag_drop_types.h"
#include "ui/base/resource/resource_bundle.h"
@@ -134,9 +135,15 @@ class DragDropTest : public test::AshTestBase {
resources_pack_path.Append(FILE_PATH_LITERAL("resources.pak"));
ResourceBundle::GetSharedInstance().AddDataPackFromPath(
resources_pack_path, ui::SCALE_FACTOR_NONE);
+ aura::Env::CreateInstance(true);
test::AshTestBase::SetUp();
}
+
+ void TearDown() override {
+ test::AshTestBase::TearDown();
+ aura::Env::DeleteInstance();
+ }
};
#if !defined(OS_CHROMEOS)
diff --git a/ash/shell.cc b/ash/shell.cc
index 4cbc6d4..ef36860 100644
--- a/ash/shell.cc
+++ b/ash/shell.cc
@@ -647,6 +647,7 @@ Shell::Shell(ShellDelegate* delegate)
simulate_modal_window_open_for_testing_(false),
is_touch_hud_projection_enabled_(false) {
DCHECK(delegate_.get());
+ DCHECK(aura::Env::GetInstanceDontCreate());
gpu_support_.reset(delegate_->CreateGPUSupport());
display_manager_.reset(new DisplayManager);
window_tree_host_manager_.reset(new WindowTreeHostManager);
@@ -881,7 +882,6 @@ void Shell::Init(const ShellInitParams& init_params) {
// Shelf, and WallPaper could be created by the factory.
views::FocusManagerFactory::Install(new AshFocusManagerFactory);
- aura::Env::CreateInstance(true);
aura::Env::GetInstance()->set_context_factory(init_params.context_factory);
// The WindowModalityController needs to be at the front of the input event
diff --git a/ash/test/ash_test_helper.cc b/ash/test/ash_test_helper.cc
index 22f16bb..177f3ad 100644
--- a/ash/test/ash_test_helper.cc
+++ b/ash/test/ash_test_helper.cc
@@ -128,7 +128,6 @@ void AshTestHelper::TearDown() {
}
#endif
- aura::Env::DeleteInstance();
ui::TerminateContextFactoryForTests();
// Need to reset the initial login status.
@@ -144,7 +143,6 @@ void AshTestHelper::TearDown() {
void AshTestHelper::RunAllPendingInMessageLoop() {
DCHECK(base::MessageLoopForUI::current() == message_loop_);
- aura::Env::CreateInstance(true);
base::RunLoop run_loop;
run_loop.RunUntilIdle();
}
diff --git a/ash/test/test_suite.cc b/ash/test/test_suite.cc
index 73de7b3..c39c76b 100644
--- a/ash/test/test_suite.cc
+++ b/ash/test/test_suite.cc
@@ -9,6 +9,7 @@
#include "base/files/file_path.h"
#include "build/build_config.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/aura/env.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/ui_base_paths.h"
#include "ui/gfx/gfx_paths.h"
@@ -58,9 +59,11 @@ void AuraShellTestSuite::Initialize() {
"en-US", NULL, ui::ResourceBundle::LOAD_COMMON_RESOURCES);
base::DiscardableMemoryAllocator::SetInstance(&discardable_memory_allocator_);
+ aura::Env::CreateInstance(true);
}
void AuraShellTestSuite::Shutdown() {
+ aura::Env::DeleteInstance();
ui::ResourceBundle::CleanupSharedInstance();
#if defined(OS_WIN)
com_initializer_.reset();
diff --git a/ash/wm/ash_native_cursor_manager_interactive_uitest.cc b/ash/wm/ash_native_cursor_manager_interactive_uitest.cc
index a7d0536..214394b 100644
--- a/ash/wm/ash_native_cursor_manager_interactive_uitest.cc
+++ b/ash/wm/ash_native_cursor_manager_interactive_uitest.cc
@@ -10,6 +10,7 @@
#include "ash/test/cursor_manager_test_api.h"
#include "base/path_service.h"
#include "base/run_loop.h"
+#include "ui/aura/env.h"
#include "ui/aura/window.h"
#include "ui/aura/window_tree_host.h"
#include "ui/base/resource/resource_bundle.h"
@@ -42,9 +43,15 @@ class AshNativeCursorManagerTest : public test::AshTestBase {
resources_pack_path.Append(FILE_PATH_LITERAL("resources.pak"));
ResourceBundle::GetSharedInstance().AddDataPackFromPath(
resources_pack_path, ui::SCALE_FACTOR_NONE);
+ aura::Env::CreateInstance(true);
test::AshTestBase::SetUp();
}
+
+ void TearDown() override {
+ test::AshTestBase::TearDown();
+ aura::Env::DeleteInstance();
+ }
};
namespace {
diff --git a/chrome/browser/browser_process_impl.cc b/chrome/browser/browser_process_impl.cc
index 2c8ef5d..756c066 100644
--- a/chrome/browser/browser_process_impl.cc
+++ b/chrome/browser/browser_process_impl.cc
@@ -111,10 +111,6 @@
#include "components/gcm_driver/gcm_client_factory.h"
#endif
-#if defined(USE_AURA)
-#include "ui/aura/env.h"
-#endif
-
#if defined(ENABLE_BACKGROUND)
#include "chrome/browser/background/background_mode_manager.h"
#endif
@@ -315,12 +311,6 @@ void BrowserProcessImpl::StartTearDown() {
// Stop the watchdog thread before stopping other threads.
watchdog_thread_.reset();
-#if defined(USE_AURA)
- // Delete aura after the metrics service has been deleted as it accesses
- // monitor information.
- aura::Env::DeleteInstance();
-#endif
-
platform_part()->StartTearDown();
#if defined(ENABLE_WEBRTC)
diff --git a/chrome/browser/chromeos/policy/status_uploader_unittest.cc b/chrome/browser/chromeos/policy/status_uploader_unittest.cc
index f77a92e..e716914 100644
--- a/chrome/browser/chromeos/policy/status_uploader_unittest.cc
+++ b/chrome/browser/chromeos/policy/status_uploader_unittest.cc
@@ -43,20 +43,6 @@ namespace em = enterprise_management;
namespace {
-// A test implementation of PlatformEventSource that we can instantiate to make
-// sure that the PlatformEventSource has an instance while in unit tests (X11
-// platforms don't have a PlatformEventSource by default, while Ozone tests do).
-#if defined(USE_X11)
-class TestPlatformEventSource : public ui::PlatformEventSource {
- public:
- TestPlatformEventSource() {}
- ~TestPlatformEventSource() override {}
-
- private:
- DISALLOW_COPY_AND_ASSIGN(TestPlatformEventSource);
-};
-#endif
-
class MockDeviceStatusCollector : public policy::DeviceStatusCollector {
public:
explicit MockDeviceStatusCollector(PrefService* local_state)
@@ -142,9 +128,6 @@ class StatusUploaderTest : public testing::Test {
scoped_refptr<base::TestSimpleTaskRunner> task_runner_;
chromeos::ScopedCrosSettingsTestHelper settings_helper_;
scoped_ptr<MockDeviceStatusCollector> collector_;
-#if defined(USE_X11)
- TestPlatformEventSource platform_event_source_;
-#endif
ui::UserActivityDetector detector_;
MockCloudPolicyClient client_;
MockDeviceManagementService device_management_service_;
diff --git a/chrome/browser/extensions/test_extension_environment.cc b/chrome/browser/extensions/test_extension_environment.cc
index 26a0674..7044795 100644
--- a/chrome/browser/extensions/test_extension_environment.cc
+++ b/chrome/browser/extensions/test_extension_environment.cc
@@ -27,10 +27,6 @@
#include "chrome/browser/chromeos/settings/device_settings_service.h"
#endif
-#if defined(USE_AURA)
-#include "ui/aura/env.h"
-#endif
-
namespace extensions {
using content::BrowserThread;
@@ -112,15 +108,9 @@ void TestExtensionEnvironment::Init() {
if (!chromeos::DeviceSettingsService::IsInitialized())
chromeos_env_.reset(new ChromeOSEnv);
#endif
-#if defined(USE_AURA)
- aura::Env::CreateInstance(true);
-#endif
}
TestExtensionEnvironment::~TestExtensionEnvironment() {
-#if defined(USE_AURA)
- aura::Env::DeleteInstance();
-#endif
}
TestingProfile* TestExtensionEnvironment::profile() const {
diff --git a/chrome/browser/ui/views/bookmarks/bookmark_context_menu_unittest.cc b/chrome/browser/ui/views/bookmarks/bookmark_context_menu_unittest.cc
index 1608880..6b63f94 100644
--- a/chrome/browser/ui/views/bookmarks/bookmark_context_menu_unittest.cc
+++ b/chrome/browser/ui/views/bookmarks/bookmark_context_menu_unittest.cc
@@ -66,7 +66,6 @@ class BookmarkContextMenuTest : public testing::Test {
}
void SetUp() override {
- event_source_ = ui::PlatformEventSource::CreateDefault();
profile_.reset(new TestingProfile());
profile_->CreateBookmarkModel(true);
@@ -82,14 +81,12 @@ class BookmarkContextMenuTest : public testing::Test {
BrowserThread::GetBlockingPool()->FlushForTesting();
// Flush the message loop to make application verifiers happy.
message_loop_.RunUntilIdle();
- event_source_.reset();
}
protected:
base::MessageLoopForUI message_loop_;
content::TestBrowserThread ui_thread_;
content::TestBrowserThread file_thread_;
- scoped_ptr<ui::PlatformEventSource> event_source_;
scoped_ptr<TestingProfile> profile_;
BookmarkModel* model_;
TestingPageNavigator navigator_;
diff --git a/chrome/test/base/chrome_render_view_host_test_harness.cc b/chrome/test/base/chrome_render_view_host_test_harness.cc
index 3aa7133..b32b8e6 100644
--- a/chrome/test/base/chrome_render_view_host_test_harness.cc
+++ b/chrome/test/base/chrome_render_view_host_test_harness.cc
@@ -16,11 +16,6 @@
#include "ash/shell.h"
#endif
-#if defined(USE_AURA)
-#include "ui/aura/env.h"
-#include "ui/aura/window_event_dispatcher.h"
-#endif
-
using content::RenderViewHostTester;
using content::RenderViewHostTestHarness;
@@ -65,9 +60,6 @@ void ChromeRenderViewHostTestHarness::TearDown() {
#if defined(USE_ASH)
ash::Shell::DeleteInstance();
#endif
-#if defined(USE_AURA)
- aura::Env::DeleteInstance();
-#endif
}
content::BrowserContext*
diff --git a/chrome/test/base/view_event_test_platform_part_chromeos.cc b/chrome/test/base/view_event_test_platform_part_chromeos.cc
index d1e9963..3767dda 100644
--- a/chrome/test/base/view_event_test_platform_part_chromeos.cc
+++ b/chrome/test/base/view_event_test_platform_part_chromeos.cc
@@ -45,6 +45,8 @@ ViewEventTestPlatformPartChromeOS::ViewEventTestPlatformPartChromeOS(
chromeos::DBusThreadManager::Initialize();
chromeos::CrasAudioHandler::InitializeForTesting();
chromeos::NetworkHandler::Initialize();
+
+ aura::Env::CreateInstance(true);
ash::test::TestShellDelegate* shell_delegate =
new ash::test::TestShellDelegate();
ash::ShellInitParams init_params;
@@ -58,14 +60,14 @@ ViewEventTestPlatformPartChromeOS::ViewEventTestPlatformPartChromeOS(
ViewEventTestPlatformPartChromeOS::~ViewEventTestPlatformPartChromeOS() {
ash::Shell::DeleteInstance();
+ aura::Env::DeleteInstance();
+
chromeos::NetworkHandler::Shutdown();
chromeos::CrasAudioHandler::Shutdown();
chromeos::DBusThreadManager::Shutdown();
// Ash Shell can't just live on its own without a browser process, we need to
// also shut down the message center.
message_center::MessageCenter::Shutdown();
-
- aura::Env::DeleteInstance();
}
} // namespace
diff --git a/content/browser/browser_main_loop.cc b/content/browser/browser_main_loop.cc
index 70f474c..a8ec5ae 100644
--- a/content/browser/browser_main_loop.cc
+++ b/content/browser/browser_main_loop.cc
@@ -923,6 +923,10 @@ void BrowserMainLoop::ShutdownThreadsAndCleanUp() {
parts_->PostMainMessageLoopRun();
}
+#if defined(USE_AURA)
+ aura::Env::DeleteInstance();
+#endif
+
trace_memory_controller_.reset();
system_stats_monitor_.reset();
diff --git a/content/browser/renderer_host/render_widget_host_unittest.cc b/content/browser/renderer_host/render_widget_host_unittest.cc
index e23ec92..a33a0cb 100644
--- a/content/browser/renderer_host/render_widget_host_unittest.cc
+++ b/content/browser/renderer_host/render_widget_host_unittest.cc
@@ -39,7 +39,6 @@
#if defined(USE_AURA)
#include "content/browser/renderer_host/render_widget_host_view_aura.h"
#include "content/browser/renderer_host/ui_events_helper.h"
-#include "ui/aura/env.h"
#include "ui/aura/test/test_screen.h"
#include "ui/events/event.h"
#endif
@@ -423,7 +422,6 @@ class RenderWidgetHostTest : public testing::Test {
}
#endif
#if defined(USE_AURA)
- aura::Env::CreateInstance(true);
screen_.reset(aura::TestScreen::Create(gfx::Size()));
gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, screen_.get());
#endif
@@ -445,7 +443,6 @@ class RenderWidgetHostTest : public testing::Test {
browser_context_.reset();
#if defined(USE_AURA)
- aura::Env::DeleteInstance();
gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, nullptr);
screen_.reset();
#endif
diff --git a/content/browser/web_contents/web_contents_view_aura.cc b/content/browser/web_contents/web_contents_view_aura.cc
index 39a2388..0a3e3a1 100644
--- a/content/browser/web_contents/web_contents_view_aura.cc
+++ b/content/browser/web_contents/web_contents_view_aura.cc
@@ -825,7 +825,7 @@ void WebContentsViewAura::CreateView(
// if the bookmark bar is not shown and you create a new tab). The right
// value is set shortly after this, so its safe to ignore.
- aura::Env::CreateInstance(true);
+ DCHECK(aura::Env::GetInstanceDontCreate());
window_.reset(new aura::Window(this));
window_->set_owned_by_parent(false);
window_->SetType(ui::wm::WINDOW_TYPE_CONTROL);
diff --git a/content/public/test/test_web_contents_factory.h b/content/public/test/test_web_contents_factory.h
index 8b48f9e..92cdcae 100644
--- a/content/public/test/test_web_contents_factory.h
+++ b/content/public/test/test_web_contents_factory.h
@@ -41,9 +41,6 @@ class TestWebContentsFactory {
// The vector of web contents that this class created.
ScopedVector<WebContents> web_contents_;
- // True if the factory initialized aura (and should thus tear it down).
- bool tear_down_aura_;
-
DISALLOW_COPY_AND_ASSIGN(TestWebContentsFactory);
};
diff --git a/content/public/test/unittest_test_suite.cc b/content/public/test/unittest_test_suite.cc
index 2a6c6b8..573838a 100644
--- a/content/public/test/unittest_test_suite.cc
+++ b/content/public/test/unittest_test_suite.cc
@@ -7,15 +7,32 @@
#include "base/logging.h"
#include "base/rand_util.h"
#include "base/test/test_suite.h"
+#include "third_party/WebKit/public/web/WebKit.h"
+
+#if defined(USE_AURA)
+#include "ui/aura/env.h"
+#endif
+
+#if defined(USE_X11)
+#include <X11/Xlib.h>
+#endif
+
#if !defined(OS_IOS)
#include "content/test/test_blink_web_unit_test_support.h"
#endif
-#include "third_party/WebKit/public/web/WebKit.h"
namespace content {
UnitTestTestSuite::UnitTestTestSuite(base::TestSuite* test_suite)
: test_suite_(test_suite) {
+#if defined(USE_X11)
+ XInitThreads();
+#endif
+#if defined(USE_AURA)
+ DCHECK(!aura::Env::GetInstanceDontCreate());
+ const bool create_event_source = true;
+ aura::Env::CreateInstance(create_event_source);
+#endif
DCHECK(test_suite);
#if !defined(OS_IOS)
blink_test_support_.reset(new TestBlinkWebUnitTestSupport);
@@ -26,6 +43,9 @@ UnitTestTestSuite::~UnitTestTestSuite() {
#if !defined(OS_IOS)
blink_test_support_.reset();
#endif
+#if defined(USE_AURA)
+ aura::Env::DeleteInstance();
+#endif
}
int UnitTestTestSuite::Run() {
diff --git a/content/test/test_web_contents_factory.cc b/content/test/test_web_contents_factory.cc
index 0bf7a01..0cbbbe8 100644
--- a/content/test/test_web_contents_factory.cc
+++ b/content/test/test_web_contents_factory.cc
@@ -9,21 +9,10 @@
#include "content/public/test/test_renderer_host.h"
#include "content/public/test/web_contents_tester.h"
-#if defined(USE_AURA)
-#include "ui/aura/env.h"
-#endif
-
namespace content {
TestWebContentsFactory::TestWebContentsFactory()
- : rvh_enabler_(new content::RenderViewHostTestEnabler()),
- tear_down_aura_(false) {
-#if defined(USE_AURA)
- if (aura::Env::GetInstanceDontCreate() == nullptr) {
- aura::Env::CreateInstance(true);
- tear_down_aura_ = true;
- }
-#endif
+ : rvh_enabler_(new content::RenderViewHostTestEnabler()) {
}
TestWebContentsFactory::~TestWebContentsFactory() {
@@ -36,10 +25,6 @@ TestWebContentsFactory::~TestWebContentsFactory() {
rvh_enabler_.reset();
// Let any posted tasks for RenderProcess/ViewHost deletion run.
base::RunLoop().RunUntilIdle();
-#if defined(USE_AURA)
- if (tear_down_aura_)
- aura::Env::DeleteInstance();
-#endif
}
WebContents* TestWebContentsFactory::CreateWebContents(
diff --git a/ui/aura/test/aura_test_helper.cc b/ui/aura/test/aura_test_helper.cc
index e98c16f..c315c82 100644
--- a/ui/aura/test/aura_test_helper.cc
+++ b/ui/aura/test/aura_test_helper.cc
@@ -34,7 +34,8 @@ namespace test {
AuraTestHelper::AuraTestHelper(base::MessageLoopForUI* message_loop)
: setup_called_(false),
- teardown_called_(false) {
+ teardown_called_(false),
+ env_created_(false) {
DCHECK(message_loop);
message_loop_ = message_loop;
// Disable animations during tests.
@@ -56,7 +57,10 @@ AuraTestHelper::~AuraTestHelper() {
void AuraTestHelper::SetUp(ui::ContextFactory* context_factory) {
setup_called_ = true;
- Env::CreateInstance(true);
+ if (!Env::GetInstanceDontCreate()) {
+ env_created_ = true;
+ Env::CreateInstance(true);
+ }
Env::GetInstance()->set_context_factory(context_factory);
// Unit tests generally don't want to query the system, rather use the state
// from RootWindow.
@@ -96,7 +100,8 @@ void AuraTestHelper::TearDown() {
ui::ShutdownInputMethodForTesting();
- Env::DeleteInstance();
+ if (env_created_)
+ Env::DeleteInstance();
}
void AuraTestHelper::RunAllPendingInMessageLoop() {
diff --git a/ui/aura/test/aura_test_helper.h b/ui/aura/test/aura_test_helper.h
index e4820f0..0cdaf3e 100644
--- a/ui/aura/test/aura_test_helper.h
+++ b/ui/aura/test/aura_test_helper.h
@@ -57,6 +57,7 @@ class AuraTestHelper {
base::MessageLoopForUI* message_loop_;
bool setup_called_;
bool teardown_called_;
+ bool env_created_;
scoped_ptr<WindowTreeHost> host_;
scoped_ptr<TestWindowTreeClient> stacking_client_;
scoped_ptr<client::DefaultCaptureClient> capture_client_;