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

Side by Side Diff: content/test/content_test_suite.cc

Issue 10191010: Re-implement the screensaver to use WebView instead of ExtensionDialogHost. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ut fix. Created 8 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « content/content_tests.gypi ('k') | content/test/test_content_client_initializer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "content/test/content_test_suite.h" 5 #include "content/test/content_test_suite.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/scoped_ptr.h"
9 #include "content/browser/mock_content_browser_client.h" 8 #include "content/browser/mock_content_browser_client.h"
10 #include "content/browser/notification_service_impl.h"
11 #include "content/public/common/content_client.h"
12 #include "content/public/common/content_paths.h" 9 #include "content/public/common/content_paths.h"
13 #include "content/public/common/url_constants.h" 10 #include "content/public/common/url_constants.h"
14 #include "content/test/test_content_client.h" 11 #include "content/test/test_content_client.h"
12 #include "content/test/test_content_client_initializer.h"
15 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
16 #include "ui/base/ui_base_paths.h" 14 #include "ui/base/ui_base_paths.h"
17 15
18 #if defined(OS_MACOSX) 16 #if defined(OS_MACOSX)
19 #include "base/mac/scoped_nsautorelease_pool.h" 17 #include "base/mac/scoped_nsautorelease_pool.h"
20 #endif 18 #endif
21 #include "ui/gfx/compositor/compositor_setup.h" 19 #include "ui/gfx/compositor/compositor_setup.h"
22 20
21
23 namespace { 22 namespace {
24 23
25 class TestContentClientInitializer : public testing::EmptyTestEventListener { 24 class TestInitializationListener : public testing::EmptyTestEventListener {
26 public: 25 public:
27 TestContentClientInitializer() { 26 TestInitializationListener() : test_content_client_initializer_(NULL) {
28 } 27 }
29 28
30 virtual void OnTestStart(const testing::TestInfo& test_info) OVERRIDE { 29 virtual void OnTestStart(const testing::TestInfo& test_info) OVERRIDE {
31 notification_service_.reset(new NotificationServiceImpl()); 30 test_content_client_initializer_ =
32 31 new content::TestContentClientInitializer();
33 DCHECK(!content::GetContentClient());
34 content_client_.reset(new TestContentClient);
35 content::SetContentClient(content_client_.get());
36
37 content_browser_client_.reset(new content::MockContentBrowserClient());
38 content_client_->set_browser(content_browser_client_.get());
39 } 32 }
40 33
41 virtual void OnTestEnd(const testing::TestInfo& test_info) OVERRIDE { 34 virtual void OnTestEnd(const testing::TestInfo& test_info) OVERRIDE {
42 notification_service_.reset(); 35 delete test_content_client_initializer_;
43
44 DCHECK_EQ(content_client_.get(), content::GetContentClient());
45 content::SetContentClient(NULL);
46 content_client_.reset();
47
48 content_browser_client_.reset();
49 } 36 }
50 37
51 private: 38 private:
52 scoped_ptr<NotificationServiceImpl> notification_service_; 39 content::TestContentClientInitializer* test_content_client_initializer_;
53 scoped_ptr<content::ContentClient> content_client_;
54 scoped_ptr<content::ContentBrowserClient> content_browser_client_;
55 40
56 DISALLOW_COPY_AND_ASSIGN(TestContentClientInitializer); 41 DISALLOW_COPY_AND_ASSIGN(TestInitializationListener);
57 }; 42 };
58 43
59 } // namespace 44 } // namespace
60 45
61 ContentTestSuite::ContentTestSuite(int argc, char** argv) 46 ContentTestSuite::ContentTestSuite(int argc, char** argv)
62 : base::TestSuite(argc, argv) { 47 : base::TestSuite(argc, argv) {
63 } 48 }
64 49
65 ContentTestSuite::~ContentTestSuite() { 50 ContentTestSuite::~ContentTestSuite() {
66 } 51 }
(...skipping 11 matching lines...) Expand all
78 content::SetContentClient(NULL); 63 content::SetContentClient(NULL);
79 64
80 content::RegisterPathProvider(); 65 content::RegisterPathProvider();
81 ui::RegisterPathProvider(); 66 ui::RegisterPathProvider();
82 67
83 // Mock out the compositor on platforms that use it. 68 // Mock out the compositor on platforms that use it.
84 ui::SetupTestCompositor(); 69 ui::SetupTestCompositor();
85 70
86 testing::TestEventListeners& listeners = 71 testing::TestEventListeners& listeners =
87 testing::UnitTest::GetInstance()->listeners(); 72 testing::UnitTest::GetInstance()->listeners();
88 listeners.Append(new TestContentClientInitializer); 73 listeners.Append(new TestInitializationListener);
89 } 74 }
90 75
OLDNEW
« no previous file with comments | « content/content_tests.gypi ('k') | content/test/test_content_client_initializer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698