Commit b80c1b5a authored by wutao's avatar wutao Committed by Commit Bot

cros: Fix UIChromeOSTestSuite.

The UIChromeOSTestSuite will fail some of the unit tests based on
views::ViewsTestBase. In the retries, the tests will pass.

By comparing UIChromeOSTestSuite and ViewsTestSuite, the only difference
is that UIChromeOSTestSuite does not init/clear up aura env.

This cl properly sets up and cleans up the aura env for UIChromeOSTestSuite.

Bug: 807148
Test: ui_chromeos_unittests
Change-Id: Ife3bae23c2003a6e219764f7483cdff7eb785c72
Reviewed-on: https://chromium-review.googlesource.com/892495
Commit-Queue: Tao Wu <wutao@chromium.org>
Reviewed-by: default avatarJames Cook <jamescook@chromium.org>
Cr-Commit-Position: refs/heads/master@{#532944}
parent 0d8afc1a
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include <memory>
#include "base/bind.h" #include "base/bind.h"
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "base/macros.h" #include "base/macros.h"
...@@ -10,6 +12,7 @@ ...@@ -10,6 +12,7 @@
#include "base/test/test_suite.h" #include "base/test/test_suite.h"
#include "mojo/edk/embedder/embedder.h" #include "mojo/edk/embedder/embedder.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "ui/aura/env.h"
#include "ui/base/resource/resource_bundle.h" #include "ui/base/resource/resource_bundle.h"
#include "ui/base/ui_base_paths.h" #include "ui/base/ui_base_paths.h"
#include "ui/gl/test/gl_surface_test_support.h" #include "ui/gl/test/gl_surface_test_support.h"
...@@ -30,14 +33,18 @@ class UIChromeOSTestSuite : public base::TestSuite { ...@@ -30,14 +33,18 @@ class UIChromeOSTestSuite : public base::TestSuite {
base::FilePath ui_test_pak_path; base::FilePath ui_test_pak_path;
ASSERT_TRUE(PathService::Get(ui::UI_TEST_PAK, &ui_test_pak_path)); ASSERT_TRUE(PathService::Get(ui::UI_TEST_PAK, &ui_test_pak_path));
ui::ResourceBundle::InitSharedInstanceWithPakPath(ui_test_pak_path); ui::ResourceBundle::InitSharedInstanceWithPakPath(ui_test_pak_path);
env_ = aura::Env::CreateInstance();
} }
void Shutdown() override { void Shutdown() override {
env_.reset();
ui::ResourceBundle::CleanupSharedInstance(); ui::ResourceBundle::CleanupSharedInstance();
base::TestSuite::Shutdown(); base::TestSuite::Shutdown();
} }
private: private:
std::unique_ptr<aura::Env> env_;
DISALLOW_COPY_AND_ASSIGN(UIChromeOSTestSuite); DISALLOW_COPY_AND_ASSIGN(UIChromeOSTestSuite);
}; };
......
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