0

Makes a couple of tests reset state appropriately

A couple of tests were setting the ScreenTypeDelegate or Screen during
Setup but never resetting during Teardown. This lead to future tests
failing.

BUG=448189
TEST=covered by tests
R=sadrul@chromium.org

Review URL: https://codereview.chromium.org/857283002

Cr-Commit-Position: refs/heads/master@{#312268}
This commit is contained in:
sky
2015-01-20 12:54:37 -08:00
committed by Commit bot
parent a42e4e1df4
commit 4a193b718a
8 changed files with 20 additions and 22 deletions

@ -80,7 +80,7 @@ class SigninErrorNotifierTest : public AshTestBase {
#if defined(OS_WIN)
test_screen_.reset(aura::TestScreen::Create(gfx::Size()));
gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, test_screen_.get());
gfx::Screen::SetScreenTypeDelegate(new ScreenTypeDelegateDesktop);
gfx::Screen::SetScreenTypeDelegate(&screen_type_delegate_);
#endif
error_controller_ = SigninErrorControllerFactory::GetForProfile(
@ -91,6 +91,8 @@ class SigninErrorNotifierTest : public AshTestBase {
void TearDown() override {
#if defined(OS_WIN)
gfx::Screen::SetScreenTypeDelegate(nullptr);
gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, nullptr);
test_screen_.reset();
#endif
profile_manager_.reset();
@ -109,6 +111,7 @@ class SigninErrorNotifierTest : public AshTestBase {
}
#if defined(OS_WIN)
ScreenTypeDelegateDesktop screen_type_delegate_;
scoped_ptr<gfx::Screen> test_screen_;
#endif
scoped_ptr<TestingProfileManager> profile_manager_;

@ -108,7 +108,7 @@ class SyncErrorNotifierTest : public AshTestBase {
#if defined(OS_WIN)
test_screen_.reset(aura::TestScreen::Create(gfx::Size()));
gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, test_screen_.get());
gfx::Screen::SetScreenTypeDelegate(new ScreenTypeDelegateDesktop);
gfx::Screen::SetScreenTypeDelegate(&screen_type_delegate_);
#endif
service_.reset(new NiceMock<ProfileSyncServiceMock>(profile_));
@ -129,6 +129,8 @@ class SyncErrorNotifierTest : public AshTestBase {
error_notifier_->Shutdown();
service_.reset();
#if defined(OS_WIN)
gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, nullptr);
gfx::Screen::SetScreenTypeDelegate(nullptr);
test_screen_.reset();
#endif
profile_manager_.reset();
@ -166,6 +168,7 @@ class SyncErrorNotifierTest : public AshTestBase {
}
#if defined(OS_WIN)
ScreenTypeDelegateDesktop screen_type_delegate_;
scoped_ptr<gfx::Screen> test_screen_;
#endif
scoped_ptr<TestingProfileManager> profile_manager_;

@ -4,6 +4,7 @@
#include "chrome/test/base/view_event_test_platform_part.h"
#include "base/memory/scoped_ptr.h"
#include "ui/aura/env.h"
#include "ui/gfx/screen.h"
#include "ui/views/widget/desktop_aura/desktop_screen.h"
@ -24,23 +25,25 @@ class ViewEventTestPlatformPartAsh : public ViewEventTestPlatformPart {
}
private:
scoped_ptr<gfx::Screen> screen_;
wm::WMState wm_state_;
DISALLOW_COPY_AND_ASSIGN(ViewEventTestPlatformPartAsh);
};
ViewEventTestPlatformPartAsh::ViewEventTestPlatformPartAsh(
ui::ContextFactory* context_factory) {
ui::ContextFactory* context_factory)
: screen_(views::CreateDesktopScreen()) {
// http://crbug.com/154081 use ash::Shell code path below on win_ash bots when
// interactive_ui_tests is brought up on that platform.
gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE,
views::CreateDesktopScreen());
gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, screen_.get());
aura::Env::CreateInstance(true);
aura::Env::GetInstance()->set_context_factory(context_factory);
}
ViewEventTestPlatformPartAsh::~ViewEventTestPlatformPartAsh() {
aura::Env::DeleteInstance();
gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, nullptr);
}
} // namespace

@ -62,6 +62,7 @@ class TouchEmulatorTest : public testing::Test,
#if defined(USE_AURA)
aura::Env::DeleteInstance();
gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, nullptr);
screen_.reset();
#endif
}

@ -458,6 +458,7 @@ class RenderWidgetHostTest : public testing::Test {
#if defined(USE_AURA)
aura::Env::DeleteInstance();
gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, nullptr);
screen_.reset();
#endif
#if defined(USE_AURA) || (defined(OS_MACOSX) && !defined(OS_IOS))

@ -705,19 +705,6 @@ content.dll!base::internal::BindState<>::`scalar deleting destructor'
base.dll!scoped_refptr<>::Release
base.dll!base::internal::CallbackBase::~CallbackBase
UNADDRESSABLE ACCESS
name=https://crbug.com/448189
...
aura.dll!aura::GetDeviceScaleFactorFromDisplay
aura.dll!aura::WindowTreeHost::InitCompositor
aura.dll!aura::WindowTreeHost::InitHost
ash.dll!ash::DisplayController::AddWindowTreeHostForDisplay
ash.dll!ash::DisplayController::CreatePrimaryHost
ash.dll!ash::Shell::Init
ash.dll!ash::Shell::CreateInstance
*!ash::test::AshTestHelper::SetUp
*!ash::test::AshTestBase::SetUp
HANDLE LEAK
name=http://crbug.com/449989
system call NtOpenProcess

@ -79,7 +79,3 @@ TranslateManagerRenderViewHostTest.*
SafeBrowsingModuleVerifierWinTest.VerifyModuleExportModified
SafeBrowsingModuleVerifierWinTest.VerifyModuleModified
SafeBrowsingModuleVerifierWinTest.VerifyModuleUnmodified
# http://crbug.com/448189
AXTreeSourceAshTest.*
ChromeScreenshotGrabberTest.TakeScreenshot

@ -37,6 +37,8 @@ class GFX_EXPORT Screen {
// Sets the global screen for a particular screen type. Only the _NATIVE
// ScreenType must be provided.
// NOTE: this does not take ownership of |screen|. Tests must be sure to
// reset any state they install.
static void SetScreenInstance(ScreenType type, Screen* instance);
// Returns the global screen for a particular type. Types other than _NATIVE
@ -45,6 +47,8 @@ class GFX_EXPORT Screen {
// Sets the global ScreenTypeDelegate. May be left unset if the platform
// uses only the _NATIVE ScreenType.
// NOTE: this does not take ownership of |delegate|. Tests must be sure to
// reset any state they install.
static void SetScreenTypeDelegate(ScreenTypeDelegate* delegate);
Screen();