Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(65)

Side by Side Diff: ui/views/run_all_unittests.cc

Issue 1871253002: aura: Require explicit ownership of the Env instance. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tot.merge Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/bind.h" 5 #include "base/bind.h"
6 #include "base/compiler_specific.h" 6 #include "base/compiler_specific.h"
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/path_service.h" 8 #include "base/path_service.h"
9 #include "base/test/launcher/unit_test_launcher.h" 9 #include "base/test/launcher/unit_test_launcher.h"
10 #include "base/test/test_suite.h" 10 #include "base/test/test_suite.h"
11 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
12 #include "ui/base/resource/resource_bundle.h" 12 #include "ui/base/resource/resource_bundle.h"
13 #include "ui/base/ui_base_paths.h" 13 #include "ui/base/ui_base_paths.h"
14 #include "ui/gl/test/gl_surface_test_support.h" 14 #include "ui/gl/test/gl_surface_test_support.h"
15 15
16 #if defined(USE_AURA) 16 #if defined(USE_AURA)
17 #include <memory>
18
17 #include "ui/aura/env.h" 19 #include "ui/aura/env.h"
18 #endif 20 #endif
19 21
20 namespace views { 22 namespace views {
21 23
22 class ViewTestSuite : public base::TestSuite { 24 class ViewTestSuite : public base::TestSuite {
23 public: 25 public:
24 ViewTestSuite(int argc, char** argv) : base::TestSuite(argc, argv) {} 26 ViewTestSuite(int argc, char** argv) : base::TestSuite(argc, argv) {}
25 27
26 protected: 28 protected:
27 void Initialize() override { 29 void Initialize() override {
28 base::TestSuite::Initialize(); 30 base::TestSuite::Initialize();
29 gfx::GLSurfaceTestSupport::InitializeOneOff(); 31 gfx::GLSurfaceTestSupport::InitializeOneOff();
30 ui::RegisterPathProvider(); 32 ui::RegisterPathProvider();
31 33
32 base::FilePath ui_test_pak_path; 34 base::FilePath ui_test_pak_path;
33 ASSERT_TRUE(PathService::Get(ui::UI_TEST_PAK, &ui_test_pak_path)); 35 ASSERT_TRUE(PathService::Get(ui::UI_TEST_PAK, &ui_test_pak_path));
34 ui::ResourceBundle::InitSharedInstanceWithPakPath(ui_test_pak_path); 36 ui::ResourceBundle::InitSharedInstanceWithPakPath(ui_test_pak_path);
35 #if defined(USE_AURA) 37 #if defined(USE_AURA)
36 aura::Env::CreateInstance(true); 38 env_ = aura::Env::CreateInstance();
37 #endif 39 #endif
38 } 40 }
39 41
40 void Shutdown() override { 42 void Shutdown() override {
41 #if defined(USE_AURA) 43 #if defined(USE_AURA)
42 aura::Env::DeleteInstance(); 44 env_.reset();
43 #endif 45 #endif
44 ui::ResourceBundle::CleanupSharedInstance(); 46 ui::ResourceBundle::CleanupSharedInstance();
45 base::TestSuite::Shutdown(); 47 base::TestSuite::Shutdown();
46 } 48 }
47 49
48 private: 50 private:
51 #if defined(USE_AURA)
52 std::unique_ptr<aura::Env> env_;
53 #endif
49 DISALLOW_COPY_AND_ASSIGN(ViewTestSuite); 54 DISALLOW_COPY_AND_ASSIGN(ViewTestSuite);
50 }; 55 };
51 56
52 int RunAllUnittests(int argc, char** argv) { 57 int RunAllUnittests(int argc, char** argv) {
53 ViewTestSuite test_suite(argc, argv); 58 ViewTestSuite test_suite(argc, argv);
54 59
55 return base::LaunchUnitTests( 60 return base::LaunchUnitTests(
56 argc, argv, base::Bind(&ViewTestSuite::Run, 61 argc, argv, base::Bind(&ViewTestSuite::Run,
57 base::Unretained(&test_suite))); 62 base::Unretained(&test_suite)));
58 } 63 }
59 64
60 } // namespace views 65 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/mus/window_manager_connection.cc ('k') | ui/views_content_client/views_content_client_main_parts_aura.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698