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

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

Issue 1004043002: Re-land: base: Implement browser process support for discardable memory. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: set allocator instance for blink tests Created 5 years, 9 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
« no previous file with comments | « content/renderer/render_thread_impl.cc ('k') | ui/app_list/test/run_all_unittests.cc » ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/blink_test_environment.h" 5 #include "content/test/blink_test_environment.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
11 #include "base/run_loop.h" 11 #include "base/run_loop.h"
12 #include "base/strings/string_tokenizer.h" 12 #include "base/strings/string_tokenizer.h"
13 #include "base/test/test_discardable_memory_shmem_allocator.h"
13 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" 14 #include "base/third_party/dynamic_annotations/dynamic_annotations.h"
14 #include "content/public/common/content_switches.h" 15 #include "content/public/common/content_switches.h"
15 #include "content/public/common/user_agent.h" 16 #include "content/public/common/user_agent.h"
16 #include "content/public/test/test_content_client_initializer.h" 17 #include "content/public/test/test_content_client_initializer.h"
17 #include "content/test/test_blink_web_unit_test_support.h" 18 #include "content/test/test_blink_web_unit_test_support.h"
18 #include "third_party/WebKit/public/web/WebCache.h" 19 #include "third_party/WebKit/public/web/WebCache.h"
19 #include "third_party/WebKit/public/web/WebKit.h" 20 #include "third_party/WebKit/public/web/WebKit.h"
20 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" 21 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h"
21 #include "url/url_util.h" 22 #include "url/url_util.h"
22 23
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 #else 61 #else
61 typedef base::MessageLoopForUI MessageLoopType; 62 typedef base::MessageLoopForUI MessageLoopType;
62 #endif 63 #endif
63 64
64 TestEnvironment() { 65 TestEnvironment() {
65 main_message_loop_.reset(new MessageLoopType); 66 main_message_loop_.reset(new MessageLoopType);
66 67
67 // TestBlinkWebUnitTestSupport must be instantiated after MessageLoopType. 68 // TestBlinkWebUnitTestSupport must be instantiated after MessageLoopType.
68 blink_test_support_.reset(new TestBlinkWebUnitTestSupport); 69 blink_test_support_.reset(new TestBlinkWebUnitTestSupport);
69 content_initializer_.reset(new content::TestContentClientInitializer()); 70 content_initializer_.reset(new content::TestContentClientInitializer());
71
72 base::DiscardableMemoryShmemAllocator::SetInstance(
73 &discardable_memory_allocator_);
70 } 74 }
71 75
72 ~TestEnvironment() { 76 ~TestEnvironment() {
73 } 77 }
74 78
75 TestBlinkWebUnitTestSupport* blink_platform_impl() const { 79 TestBlinkWebUnitTestSupport* blink_platform_impl() const {
76 return blink_test_support_.get(); 80 return blink_test_support_.get();
77 } 81 }
78 82
79 private: 83 private:
80 scoped_ptr<MessageLoopType> main_message_loop_; 84 scoped_ptr<MessageLoopType> main_message_loop_;
81 scoped_ptr<TestBlinkWebUnitTestSupport> blink_test_support_; 85 scoped_ptr<TestBlinkWebUnitTestSupport> blink_test_support_;
82 scoped_ptr<TestContentClientInitializer> content_initializer_; 86 scoped_ptr<TestContentClientInitializer> content_initializer_;
87 base::TestDiscardableMemoryShmemAllocator discardable_memory_allocator_;
83 }; 88 };
84 89
85 TestEnvironment* test_environment; 90 TestEnvironment* test_environment;
86 91
87 } // namespace 92 } // namespace
88 93
89 void SetUpBlinkTestEnvironment() { 94 void SetUpBlinkTestEnvironment() {
90 ParseBlinkCommandLineArgumentsForUnitTests(); 95 ParseBlinkCommandLineArgumentsForUnitTests();
91 96
92 blink::WebRuntimeFeatures::enableExperimentalFeatures(true); 97 blink::WebRuntimeFeatures::enableExperimentalFeatures(true);
(...skipping 24 matching lines...) Expand all
117 // http://code.google.com/p/chromium/issues/detail?id=9500 122 // http://code.google.com/p/chromium/issues/detail?id=9500
118 base::RunLoop().RunUntilIdle(); 123 base::RunLoop().RunUntilIdle();
119 124
120 if (RunningOnValgrind()) 125 if (RunningOnValgrind())
121 blink::WebCache::clear(); 126 blink::WebCache::clear();
122 delete test_environment; 127 delete test_environment;
123 test_environment = NULL; 128 test_environment = NULL;
124 } 129 }
125 130
126 } // namespace content 131 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_thread_impl.cc ('k') | ui/app_list/test/run_all_unittests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698