Commit 2997d2df authored by sky's avatar sky Committed by Commit bot

Fixes to get view_manager_lib_unittests not crash

. ICU may be initialized twice: once by the test suite, secondly by
  the app.
. window_mamanger_app_.host_ may be deleted by the time we get to the
  destructor to try and remove something. Add check for this.

BUG=none
TEST=none
R=viettrungluu@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#292929}
parent b30db426
...@@ -265,7 +265,10 @@ class WindowManager ...@@ -265,7 +265,10 @@ class WindowManager
app_(NULL) {} app_(NULL) {}
virtual ~WindowManager() { virtual ~WindowManager() {
window_manager_app_->host()->window()->RemovePreTargetHandler(this); // host() may be destroyed by the time we get here.
// TODO: figure out a way to always cleanly remove handler.
if (window_manager_app_->host())
window_manager_app_->host()->window()->RemovePreTargetHandler(this);
} }
void CloseWindow(Id view_id) { void CloseWindow(Id view_id) {
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "mojo/services/public/cpp/view_manager/lib/view_manager_test_suite.h" #include "mojo/services/public/cpp/view_manager/lib/view_manager_test_suite.h"
#include "base/i18n/icu_util.h"
#include "ui/gl/gl_surface.h" #include "ui/gl/gl_surface.h"
#if defined(USE_X11) #if defined(USE_X11)
...@@ -27,6 +28,9 @@ void ViewManagerTestSuite::Initialize() { ...@@ -27,6 +28,9 @@ void ViewManagerTestSuite::Initialize() {
base::TestSuite::Initialize(); base::TestSuite::Initialize();
gfx::GLSurface::InitializeOneOffForTests(); gfx::GLSurface::InitializeOneOffForTests();
// base::TestSuite and ViewsInit both try to load icu. That's ok for tests.
base::i18n::AllowMultipleInitializeCallsForTesting();
} }
} // namespace mojo } // namespace mojo
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment