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

Side by Side Diff: chrome/renderer/safe_browsing/phishing_dom_feature_extractor_unittest.cc

Issue 3092010: One more PhishingDOMFeatureExtractorTest suppression, for the IPC channel name. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Created 10 years, 4 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 | « no previous file | tools/heapcheck/suppressions.txt » ('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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "chrome/renderer/safe_browsing/phishing_dom_feature_extractor.h" 5 #include "chrome/renderer/safe_browsing/phishing_dom_feature_extractor.h"
6 6
7 #include <string.h> // for memcpy() 7 #include <string.h> // for memcpy()
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 // but we use a real RenderThread so that we can use the ResourceDispatcher 62 // but we use a real RenderThread so that we can use the ResourceDispatcher
63 // to fetch network resources. These are then served canned content 63 // to fetch network resources. These are then served canned content
64 // in OnRequestResource(). 64 // in OnRequestResource().
65 sandbox_init_wrapper_.reset(new SandboxInitWrapper); 65 sandbox_init_wrapper_.reset(new SandboxInitWrapper);
66 command_line_.reset(new CommandLine(CommandLine::ARGUMENTS_ONLY)); 66 command_line_.reset(new CommandLine(CommandLine::ARGUMENTS_ONLY));
67 params_.reset(new MainFunctionParams(*command_line_, 67 params_.reset(new MainFunctionParams(*command_line_,
68 *sandbox_init_wrapper_, NULL)); 68 *sandbox_init_wrapper_, NULL));
69 platform_.reset(new RendererMainPlatformDelegate(*params_)); 69 platform_.reset(new RendererMainPlatformDelegate(*params_));
70 platform_->PlatformInitialize(); 70 platform_->PlatformInitialize();
71 71
72 // We use a new IPC channel name for each test that runs. 72 std::string thread_name = GetNextThreadName();
73 // This is necessary because the renderer-side IPC channel is not
74 // shut down when the RenderThread goes away, so attempting to reuse
75 // the channel name gives an error (see ChildThread::~ChildThread()).
76 std::string thread_name = StringPrintf(
77 "phishing_dom_feature_Extractor_unittest.%d",
78 next_thread_id_++);
79 channel_.reset(new IPC::Channel(thread_name, 73 channel_.reset(new IPC::Channel(thread_name,
80 IPC::Channel::MODE_SERVER, this)); 74 IPC::Channel::MODE_SERVER, this));
81 ASSERT_TRUE(channel_->Connect()); 75 ASSERT_TRUE(channel_->Connect());
82 76
83 webkit_glue::SetJavaScriptFlags("--expose-gc"); 77 webkit_glue::SetJavaScriptFlags("--expose-gc");
84 mock_process_.reset(new MockRenderProcess); 78 mock_process_.reset(new MockRenderProcess);
85 render_thread_ = new RenderThread(thread_name); 79 render_thread_ = new RenderThread(thread_name);
86 mock_process_->set_main_thread(render_thread_); 80 mock_process_->set_main_thread(render_thread_);
87 81
88 // Tell the renderer to create a view, then wait until it's ready. 82 // Tell the renderer to create a view, then wait until it's ready.
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 193
200 // Notification that the render view we've created is ready to use. 194 // Notification that the render view we've created is ready to use.
201 void OnRenderViewReady() { 195 void OnRenderViewReady() {
202 // Grab a pointer to the new view using RenderViewVisitor. 196 // Grab a pointer to the new view using RenderViewVisitor.
203 ASSERT_TRUE(!view_); 197 ASSERT_TRUE(!view_);
204 RenderView::ForEach(this); 198 RenderView::ForEach(this);
205 ASSERT_TRUE(view_); 199 ASSERT_TRUE(view_);
206 msg_loop_.Quit(); 200 msg_loop_.Quit();
207 } 201 }
208 202
203 // We use a new IPC channel name for each test that runs.
204 // This is necessary because the renderer-side IPC channel is not
205 // shut down when the RenderThread goes away, so attempting to reuse
206 // the channel name gives an error (see ChildThread::~ChildThread()).
207 static std::string GetNextThreadName() {
208 return StringPrintf(
209 "phishing_dom_feature_Extractor_unittest.%d",
210 next_thread_id_++);
211 }
212
209 static int next_thread_id_; // incrementing counter for thread ids 213 static int next_thread_id_; // incrementing counter for thread ids
210 static const int32 kViewId = 5; // arbitrary id for our testing view 214 static const int32 kViewId = 5; // arbitrary id for our testing view
211 215
212 MessageLoopForIO msg_loop_; 216 MessageLoopForIO msg_loop_;
213 // channel that the renderer uses to talk to the browser. 217 // channel that the renderer uses to talk to the browser.
214 // For this test, we will handle the browser end of the channel. 218 // For this test, we will handle the browser end of the channel.
215 scoped_ptr<IPC::Channel> channel_; 219 scoped_ptr<IPC::Channel> channel_;
216 RenderThread* render_thread_; // owned by mock_process_ 220 RenderThread* render_thread_; // owned by mock_process_
217 scoped_ptr<MockRenderProcess> mock_process_; 221 scoped_ptr<MockRenderProcess> mock_process_;
218 RenderView* view_; // not owned, deletes itself on close 222 RenderView* view_; // not owned, deletes itself on close
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 FeatureMap features; 405 FeatureMap features;
402 LoadURL("http://host.com/"); 406 LoadURL("http://host.com/");
403 ASSERT_TRUE(ExtractFeatures(&features)); 407 ASSERT_TRUE(ExtractFeatures(&features));
404 EXPECT_THAT(features.features(), ContainerEq(expected_features.features())); 408 EXPECT_THAT(features.features(), ContainerEq(expected_features.features()));
405 } 409 }
406 410
407 // TODO(bryner): Test extraction with multiple passes, including the case where 411 // TODO(bryner): Test extraction with multiple passes, including the case where
408 // the node we stopped on is removed from the document. 412 // the node we stopped on is removed from the document.
409 413
410 } // namespace safe_browsing 414 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « no previous file | tools/heapcheck/suppressions.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698