Skip to content

Commit

Permalink
ash: removes checks for supplying aura::Env to Window's constructor
Browse files Browse the repository at this point in the history
This made sense with SingleProcessMash, where we would have two aura::Envs.
As we're no longer doing mash, that restriction is no longer applicable.

BUG=958116
TEST=none

Change-Id: Idabfcebb5da1f0052d31eda44b221fb08748f38a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1611113
Reviewed-by: Evan Stade <estade@chromium.org>
Commit-Queue: Scott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#659673}
  • Loading branch information
Scott Violet authored and Commit Bot committed May 14, 2019
1 parent 103a966 commit 77eb3a1
Show file tree
Hide file tree
Showing 10 changed files with 2 additions and 83 deletions.
4 changes: 0 additions & 4 deletions ash/test/ash_test_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,6 @@ void AshTestBase::UpdateDisplay(const std::string& display_specs) {
.UpdateNaturalOrientation();
}

void AshTestBase::SetRunningOutsideAsh() {
ash_test_helper_->SetRunningOutsideAsh();
}

aura::Window* AshTestBase::CurrentContext() {
return ash_test_helper_->CurrentContext();
}
Expand Down
6 changes: 0 additions & 6 deletions ash/test/ash_test_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,6 @@ class AshTestBase : public testing::Test {
// some environments. Use this to destroy it.
void DestroyScopedTaskEnvironment();

// Call this only if this code is being run outside of ash, for example, in
// browser tests that use AshTestBase. This disables CHECKs that are
// applicable only when used inside ash.
// TODO: remove this and ban usage of AshTestBase outside of ash.
void SetRunningOutsideAsh();

// Update the display configuration as given in |display_specs|.
// See ash::DisplayManagerTestApi::UpdateDisplay for more details.
void UpdateDisplay(const std::string& display_specs);
Expand Down
17 changes: 0 additions & 17 deletions ash/test/ash_test_helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,6 @@ AshTestHelper::~AshTestHelper() {
}

void AshTestHelper::SetUp(bool start_session, bool provide_local_state) {
#if !defined(NDEBUG)
aura::Window::SetEnvArgRequired(
"Within ash you must supply a non-null aura::Env when creating a Window, "
"use window_factory, or supply the Env obtained from "
"Shell::Get()->aura_env()");
#endif

// TODO(jamescook): Can we do this without changing command line?
// Use the origin (1,1) so that it doesn't over
// lap with the native mouse cursor.
Expand Down Expand Up @@ -238,23 +231,13 @@ void AshTestHelper::TearDown() {
display::Display::ResetForceDeviceScaleFactorForTesting();

CHECK(!::wm::CaptureController::Get());
#if !defined(NDEBUG)
aura::Window::SetEnvArgRequired(nullptr);
#endif

ui::test::EventGeneratorDelegate::SetFactoryFunction(
ui::test::EventGeneratorDelegate::FactoryFunction());

statistics_provider_.reset();
}

void AshTestHelper::SetRunningOutsideAsh() {
test_views_delegate_->set_running_outside_ash();
#if DCHECK_IS_ON()
aura::Window::SetEnvArgRequired(nullptr);
#endif
}

PrefService* AshTestHelper::GetLocalStatePrefService() {
return Shell::Get()->local_state_;
}
Expand Down
6 changes: 0 additions & 6 deletions ash/test/ash_test_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,6 @@ class AshTestHelper {
// Destroys the ash::Shell and performs associated cleanup.
void TearDown();

// Call this only if this code is being run outside of ash, for example, in
// browser tests that use AshTestBase. This disables CHECKs that are
// applicable only when used inside ash.
// TODO: remove this and ban usage of AshTestHelper outside of ash.
void SetRunningOutsideAsh();

// Returns a root Window. Usually this is the active root Window, but that
// method can return NULL sometimes, and in those cases, we fall back on the
// primary root Window.
Expand Down
18 changes: 2 additions & 16 deletions ash/test/ash_test_views_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include "ash/test/ash_test_views_delegate.h"

#include "ash/shell.h"
#include "ui/base/ui_base_features.h"

namespace ash {

Expand All @@ -16,21 +15,8 @@ AshTestViewsDelegate::~AshTestViewsDelegate() = default;
void AshTestViewsDelegate::OnBeforeWidgetInit(
views::Widget::InitParams* params,
views::internal::NativeWidgetDelegate* delegate) {
if (running_outside_ash_) {
// With Mash, MusClient::CreateNativeWidget uses a DesktopNativeWidgetAura,
// which doesn't need a context.
if (!features::IsUsingWindowService()) {
DCHECK(ash::Shell::HasInstance());
if (!params->parent && !params->context)
params->context = Shell::GetRootWindowForNewWindows();
}
} else {
CHECK(params->native_widget || params->context || params->parent)
<< "Widgets must be created with a context or parent. In tests use "
<< "CurrentContext(). In non-test code you likely want to use the "
<< "parent the Widget will be added to, or possibly "
<< "Shell::GetRootWindowForNewWindows().";
}
if (!params->parent && !params->context)
params->context = Shell::GetRootWindowForNewWindows();

TestViewsDelegate::OnBeforeWidgetInit(params, delegate);
}
Expand Down
8 changes: 0 additions & 8 deletions ash/test/ash_test_views_delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@ class AshTestViewsDelegate : public views::TestViewsDelegate {
AshTestViewsDelegate();
~AshTestViewsDelegate() override;

// Call this only if this code is being run outside of ash, for example, in
// browser tests that use AshTestBase. This disables CHECKs that are
// applicable only when used inside ash.
// TODO: remove this and ban usage of AshTestHelper outside of ash.
void set_running_outside_ash() { running_outside_ash_ = true; }

// Overriden from TestViewsDelegate.
void OnBeforeWidgetInit(
views::Widget::InitParams* params,
Expand All @@ -41,8 +35,6 @@ class AshTestViewsDelegate : public views::TestViewsDelegate {
// matches with this.
ui::Accelerator close_menu_accelerator_;

bool running_outside_ash_ = false;

DISALLOW_COPY_AND_ASSIGN(AshTestViewsDelegate);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ class ArcInputMethodManagerServiceTest : public ChromeAshTestBase {

void SetUp() override {
ChromeAshTestBase::SetUp();
SetRunningOutsideAsh();
ui::IMEBridge::Initialize();
input_method_manager_ = new TestInputMethodManager();
chromeos::input_method::InputMethodManager::Initialize(
Expand Down
1 change: 0 additions & 1 deletion chrome/test/base/browser_with_test_window_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ void BrowserWithTestWindowTest::SetUp() {
testing::Test::SetUp();
#if defined(OS_CHROMEOS)
ash_test_helper_.SetUp(true);
ash_test_helper_.SetRunningOutsideAsh();
#elif defined(TOOLKIT_VIEWS)
views_test_helper_.reset(new views::ScopedViewsTestHelper());
#endif
Expand Down
17 changes: 0 additions & 17 deletions ui/aura/window.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,6 @@
#include "ui/gfx/scoped_canvas.h"

namespace aura {
namespace {
#if DCHECK_IS_ON()
const char* g_env_arg_required_string = nullptr;
#endif

} // namespace

Window::Window(WindowDelegate* delegate, client::WindowType type, Env* env)
: Window(delegate, nullptr, type, env) {}
Expand Down Expand Up @@ -86,10 +80,6 @@ Window::Window(WindowDelegate* delegate,
// notification (such as the workspace code).
observers_(base::ObserverListPolicy::EXISTING_ONLY) {
SetTargetHandler(delegate_);
#if DCHECK_IS_ON()
// NOTE: at the time of adding this this function is only called from ash.
DCHECK(env || !g_env_arg_required_string) << g_env_arg_required_string;
#endif
}

Window::~Window() {
Expand Down Expand Up @@ -1245,13 +1235,6 @@ void Window::NotifyResizeLoopEnded() {
observer.OnResizeLoopEnded(this);
}

#if DCHECK_IS_ON()
// static
void Window::SetEnvArgRequired(const char* error_string) {
g_env_arg_required_string = error_string;
}
#endif

void Window::OnPaintLayer(const ui::PaintContext& context) {
Paint(context);
}
Expand Down
7 changes: 0 additions & 7 deletions ui/aura/window.h
Original file line number Diff line number Diff line change
Expand Up @@ -462,13 +462,6 @@ class AURA_EXPORT Window : public ui::LayerDelegate,
void NotifyResizeLoopStarted();
void NotifyResizeLoopEnded();

#if DCHECK_IS_ON()
// If passed a non-null value then a non-null aura::Env must be supplied to
// the constructor. |error_string| is the string supplied to the DCHECK
// calls.
static void SetEnvArgRequired(const char* error_string);
#endif

// ui::GestureConsumer:
bool RequiresDoubleTapGestureEvents() const override;

Expand Down

0 comments on commit 77eb3a1

Please sign in to comment.