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

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

Issue 8573018: Convert to base::Callback in safe_browsing client-side-detection code. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Don't call Run() on null callbacks. Created 9 years 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 // Note: this test uses RenderViewFakeResourcesTest in order to set up a 5 // Note: this test uses RenderViewFakeResourcesTest in order to set up a
6 // real RenderThread to hold the phishing Scorer object. 6 // real RenderThread to hold the phishing Scorer object.
7 7
8 #include "chrome/renderer/safe_browsing/phishing_classifier_delegate.h" 8 #include "chrome/renderer/safe_browsing/phishing_classifier_delegate.h"
9 9
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
12 #include "chrome/common/safe_browsing/csd.pb.h" 12 #include "chrome/common/safe_browsing/csd.pb.h"
13 #include "chrome/common/safe_browsing/safebrowsing_messages.h" 13 #include "chrome/common/safe_browsing/safebrowsing_messages.h"
14 #include "chrome/renderer/safe_browsing/features.h" 14 #include "chrome/renderer/safe_browsing/features.h"
15 #include "chrome/renderer/safe_browsing/phishing_classifier.h" 15 #include "chrome/renderer/safe_browsing/phishing_classifier.h"
16 #include "chrome/renderer/safe_browsing/scorer.h" 16 #include "chrome/renderer/safe_browsing/scorer.h"
17 #include "content/public/renderer/render_view.h" 17 #include "content/public/renderer/render_view.h"
18 #include "content/test/render_view_fake_resources_test.h" 18 #include "content/test/render_view_fake_resources_test.h"
19 #include "googleurl/src/gurl.h" 19 #include "googleurl/src/gurl.h"
20 #include "testing/gmock/include/gmock/gmock.h" 20 #include "testing/gmock/include/gmock/gmock.h"
21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" 21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebHistoryItem.h" 22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebHistoryItem.h"
23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURL.h" 23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURL.h"
24 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLRequest.h" 24 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLRequest.h"
25 25
26 using ::testing::_; 26 using ::testing::_;
27 using ::testing::DeleteArg;
28 using ::testing::InSequence; 27 using ::testing::InSequence;
29 using ::testing::Mock; 28 using ::testing::Mock;
30 using ::testing::Pointee; 29 using ::testing::Pointee;
31 using ::testing::StrictMock; 30 using ::testing::StrictMock;
32 31
33 namespace safe_browsing { 32 namespace safe_browsing {
34 33
35 namespace { 34 namespace {
36 class MockPhishingClassifier : public PhishingClassifier { 35 class MockPhishingClassifier : public PhishingClassifier {
37 public: 36 public:
38 explicit MockPhishingClassifier(content::RenderView* render_view) 37 explicit MockPhishingClassifier(content::RenderView* render_view)
39 : PhishingClassifier(render_view, NULL /* clock */) {} 38 : PhishingClassifier(render_view, NULL /* clock */) {}
40 39
41 virtual ~MockPhishingClassifier() {} 40 virtual ~MockPhishingClassifier() {}
42 41
43 MOCK_METHOD2(BeginClassification, void(const string16*, DoneCallback*)); 42 MOCK_METHOD2(BeginClassification, void(const string16*, const DoneCallback&));
44 MOCK_METHOD0(CancelPendingClassification, void()); 43 MOCK_METHOD0(CancelPendingClassification, void());
45 44
46 private: 45 private:
47 DISALLOW_COPY_AND_ASSIGN(MockPhishingClassifier); 46 DISALLOW_COPY_AND_ASSIGN(MockPhishingClassifier);
48 }; 47 };
49 48
50 class MockScorer : public Scorer { 49 class MockScorer : public Scorer {
51 public: 50 public:
52 MockScorer() : Scorer() {} 51 MockScorer() : Scorer() {}
53 virtual ~MockScorer() {} 52 virtual ~MockScorer() {}
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 EXPECT_CALL(*classifier, CancelPendingClassification()).Times(2); 111 EXPECT_CALL(*classifier, CancelPendingClassification()).Times(2);
113 responses_["http://host.com/"] = 112 responses_["http://host.com/"] =
114 "<html><body><iframe src=\"http://sub1.com/\"></iframe></body></html>"; 113 "<html><body><iframe src=\"http://sub1.com/\"></iframe></body></html>";
115 LoadURL("http://host.com/"); 114 LoadURL("http://host.com/");
116 Mock::VerifyAndClearExpectations(classifier); 115 Mock::VerifyAndClearExpectations(classifier);
117 OnStartPhishingDetection(delegate, GURL("http://host.com/")); 116 OnStartPhishingDetection(delegate, GURL("http://host.com/"));
118 string16 page_text = ASCIIToUTF16("dummy"); 117 string16 page_text = ASCIIToUTF16("dummy");
119 { 118 {
120 InSequence s; 119 InSequence s;
121 EXPECT_CALL(*classifier, CancelPendingClassification()); 120 EXPECT_CALL(*classifier, CancelPendingClassification());
122 EXPECT_CALL(*classifier, BeginClassification(Pointee(page_text), _)). 121 EXPECT_CALL(*classifier, BeginClassification(Pointee(page_text), _));
123 WillOnce(DeleteArg<1>());
124 delegate->PageCaptured(&page_text, false); 122 delegate->PageCaptured(&page_text, false);
125 Mock::VerifyAndClearExpectations(classifier); 123 Mock::VerifyAndClearExpectations(classifier);
126 } 124 }
127 125
128 // Reloading the same page should not trigger a reclassification. 126 // Reloading the same page should not trigger a reclassification.
129 // However, it will cancel any pending classification since the 127 // However, it will cancel any pending classification since the
130 // content is being replaced. 128 // content is being replaced.
131 EXPECT_CALL(*classifier, CancelPendingClassification()).Times(2); 129 EXPECT_CALL(*classifier, CancelPendingClassification()).Times(2);
132 GetMainFrame()->reload(); 130 GetMainFrame()->reload();
133 message_loop_.Run(); 131 message_loop_.Run();
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 163
166 // Now load a new toplevel page, which should trigger another classification. 164 // Now load a new toplevel page, which should trigger another classification.
167 EXPECT_CALL(*classifier, CancelPendingClassification()); 165 EXPECT_CALL(*classifier, CancelPendingClassification());
168 LoadURL("http://host2.com/"); 166 LoadURL("http://host2.com/");
169 Mock::VerifyAndClearExpectations(classifier); 167 Mock::VerifyAndClearExpectations(classifier);
170 page_text = ASCIIToUTF16("dummy2"); 168 page_text = ASCIIToUTF16("dummy2");
171 OnStartPhishingDetection(delegate, GURL("http://host2.com/")); 169 OnStartPhishingDetection(delegate, GURL("http://host2.com/"));
172 { 170 {
173 InSequence s; 171 InSequence s;
174 EXPECT_CALL(*classifier, CancelPendingClassification()); 172 EXPECT_CALL(*classifier, CancelPendingClassification());
175 EXPECT_CALL(*classifier, BeginClassification(Pointee(page_text), _)). 173 EXPECT_CALL(*classifier, BeginClassification(Pointee(page_text), _));
176 WillOnce(DeleteArg<1>());
177 delegate->PageCaptured(&page_text, false); 174 delegate->PageCaptured(&page_text, false);
178 Mock::VerifyAndClearExpectations(classifier); 175 Mock::VerifyAndClearExpectations(classifier);
179 } 176 }
180 177
181 // No classification should happen on back/forward navigation. 178 // No classification should happen on back/forward navigation.
182 // Note: in practice, the browser will not send a StartPhishingDetection IPC 179 // Note: in practice, the browser will not send a StartPhishingDetection IPC
183 // in this case. However, we want to make sure that the delegate behaves 180 // in this case. However, we want to make sure that the delegate behaves
184 // correctly regardless. 181 // correctly regardless.
185 WebKit::WebHistoryItem forward_item = GetMainFrame()->currentHistoryItem(); 182 WebKit::WebHistoryItem forward_item = GetMainFrame()->currentHistoryItem();
186 EXPECT_CALL(*classifier, CancelPendingClassification()); 183 EXPECT_CALL(*classifier, CancelPendingClassification());
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 delegate->PageCaptured(&page_text, false); 237 delegate->PageCaptured(&page_text, false);
241 238
242 LoadURL("http://host2.com/"); 239 LoadURL("http://host2.com/");
243 page_text = ASCIIToUTF16("dummy2"); 240 page_text = ASCIIToUTF16("dummy2");
244 OnStartPhishingDetection(delegate, GURL("http://host2.com/")); 241 OnStartPhishingDetection(delegate, GURL("http://host2.com/"));
245 delegate->PageCaptured(&page_text, false); 242 delegate->PageCaptured(&page_text, false);
246 243
247 // Now set a scorer, which should cause a classifier to be created and 244 // Now set a scorer, which should cause a classifier to be created and
248 // the classification to proceed. 245 // the classification to proceed.
249 page_text = ASCIIToUTF16("dummy2"); 246 page_text = ASCIIToUTF16("dummy2");
250 EXPECT_CALL(*classifier, BeginClassification(Pointee(page_text), _)). 247 EXPECT_CALL(*classifier, BeginClassification(Pointee(page_text), _));
251 WillOnce(DeleteArg<1>());
252 MockScorer scorer; 248 MockScorer scorer;
253 delegate->SetPhishingScorer(&scorer); 249 delegate->SetPhishingScorer(&scorer);
254 Mock::VerifyAndClearExpectations(classifier); 250 Mock::VerifyAndClearExpectations(classifier);
255 251
256 // If we set a new scorer while a classification is going on the 252 // If we set a new scorer while a classification is going on the
257 // classification should be cancelled. 253 // classification should be cancelled.
258 EXPECT_CALL(*classifier, CancelPendingClassification()); 254 EXPECT_CALL(*classifier, CancelPendingClassification());
259 delegate->SetPhishingScorer(&scorer); 255 delegate->SetPhishingScorer(&scorer);
260 Mock::VerifyAndClearExpectations(classifier); 256 Mock::VerifyAndClearExpectations(classifier);
261 257
(...skipping 17 matching lines...) Expand all
279 delegate->PageCaptured(&page_text, false); 275 delegate->PageCaptured(&page_text, false);
280 276
281 LoadURL("http://host.com/#foo"); 277 LoadURL("http://host.com/#foo");
282 OnStartPhishingDetection(delegate, GURL("http://host.com/#foo")); 278 OnStartPhishingDetection(delegate, GURL("http://host.com/#foo"));
283 page_text = ASCIIToUTF16("dummy"); 279 page_text = ASCIIToUTF16("dummy");
284 delegate->PageCaptured(&page_text, false); 280 delegate->PageCaptured(&page_text, false);
285 281
286 // Now set a scorer, which should cause a classifier to be created and 282 // Now set a scorer, which should cause a classifier to be created and
287 // the classification to proceed. 283 // the classification to proceed.
288 page_text = ASCIIToUTF16("dummy"); 284 page_text = ASCIIToUTF16("dummy");
289 EXPECT_CALL(*classifier, BeginClassification(Pointee(page_text), _)). 285 EXPECT_CALL(*classifier, BeginClassification(Pointee(page_text), _));
290 WillOnce(DeleteArg<1>());
291 MockScorer scorer; 286 MockScorer scorer;
292 delegate->SetPhishingScorer(&scorer); 287 delegate->SetPhishingScorer(&scorer);
293 Mock::VerifyAndClearExpectations(classifier); 288 Mock::VerifyAndClearExpectations(classifier);
294 289
295 // The delegate will cancel pending classification on destruction. 290 // The delegate will cancel pending classification on destruction.
296 EXPECT_CALL(*classifier, CancelPendingClassification()); 291 EXPECT_CALL(*classifier, CancelPendingClassification());
297 } 292 }
298 293
299 TEST_F(PhishingClassifierDelegateTest, NoStartPhishingDetection) { 294 TEST_F(PhishingClassifierDelegateTest, NoStartPhishingDetection) {
300 // Tests the behavior when OnStartPhishingDetection has not yet been called 295 // Tests the behavior when OnStartPhishingDetection has not yet been called
(...skipping 10 matching lines...) Expand all
311 responses_["http://host.com/"] = "<html><body>phish</body></html>"; 306 responses_["http://host.com/"] = "<html><body>phish</body></html>";
312 LoadURL("http://host.com/"); 307 LoadURL("http://host.com/");
313 Mock::VerifyAndClearExpectations(classifier); 308 Mock::VerifyAndClearExpectations(classifier);
314 string16 page_text = ASCIIToUTF16("phish"); 309 string16 page_text = ASCIIToUTF16("phish");
315 EXPECT_CALL(*classifier, CancelPendingClassification()); 310 EXPECT_CALL(*classifier, CancelPendingClassification());
316 delegate->PageCaptured(&page_text, false); 311 delegate->PageCaptured(&page_text, false);
317 Mock::VerifyAndClearExpectations(classifier); 312 Mock::VerifyAndClearExpectations(classifier);
318 // Now simulate the StartPhishingDetection IPC. We expect classification 313 // Now simulate the StartPhishingDetection IPC. We expect classification
319 // to begin. 314 // to begin.
320 page_text = ASCIIToUTF16("phish"); 315 page_text = ASCIIToUTF16("phish");
321 EXPECT_CALL(*classifier, BeginClassification(Pointee(page_text), _)). 316 EXPECT_CALL(*classifier, BeginClassification(Pointee(page_text), _));
322 WillOnce(DeleteArg<1>());
323 OnStartPhishingDetection(delegate, GURL("http://host.com/")); 317 OnStartPhishingDetection(delegate, GURL("http://host.com/"));
324 Mock::VerifyAndClearExpectations(classifier); 318 Mock::VerifyAndClearExpectations(classifier);
325 319
326 // Now try again, but this time we will navigate the page away before 320 // Now try again, but this time we will navigate the page away before
327 // the IPC is sent. 321 // the IPC is sent.
328 EXPECT_CALL(*classifier, CancelPendingClassification()); 322 EXPECT_CALL(*classifier, CancelPendingClassification());
329 responses_["http://host2.com/"] = "<html><body>phish</body></html>"; 323 responses_["http://host2.com/"] = "<html><body>phish</body></html>";
330 LoadURL("http://host2.com/"); 324 LoadURL("http://host2.com/");
331 Mock::VerifyAndClearExpectations(classifier); 325 Mock::VerifyAndClearExpectations(classifier);
332 page_text = ASCIIToUTF16("phish"); 326 page_text = ASCIIToUTF16("phish");
(...skipping 21 matching lines...) Expand all
354 Mock::VerifyAndClearExpectations(classifier); 348 Mock::VerifyAndClearExpectations(classifier);
355 responses_["http://host4.com/redir"] = "<html><body>123</body></html>"; 349 responses_["http://host4.com/redir"] = "<html><body>123</body></html>";
356 EXPECT_CALL(*classifier, CancelPendingClassification()); 350 EXPECT_CALL(*classifier, CancelPendingClassification());
357 LoadURL("javascript:location.replace(\'redir\');"); 351 LoadURL("javascript:location.replace(\'redir\');");
358 Mock::VerifyAndClearExpectations(classifier); 352 Mock::VerifyAndClearExpectations(classifier);
359 OnStartPhishingDetection(delegate, GURL("http://host4.com/redir")); 353 OnStartPhishingDetection(delegate, GURL("http://host4.com/redir"));
360 page_text = ASCIIToUTF16("123"); 354 page_text = ASCIIToUTF16("123");
361 { 355 {
362 InSequence s; 356 InSequence s;
363 EXPECT_CALL(*classifier, CancelPendingClassification()); 357 EXPECT_CALL(*classifier, CancelPendingClassification());
364 EXPECT_CALL(*classifier, BeginClassification(Pointee(page_text), _)) 358 EXPECT_CALL(*classifier, BeginClassification(Pointee(page_text), _));
365 .WillOnce(DeleteArg<1>());
366 delegate->PageCaptured(&page_text, false); 359 delegate->PageCaptured(&page_text, false);
367 Mock::VerifyAndClearExpectations(classifier); 360 Mock::VerifyAndClearExpectations(classifier);
368 } 361 }
369 362
370 // The delegate will cancel pending classification on destruction. 363 // The delegate will cancel pending classification on destruction.
371 EXPECT_CALL(*classifier, CancelPendingClassification()); 364 EXPECT_CALL(*classifier, CancelPendingClassification());
372 } 365 }
373 366
374 TEST_F(PhishingClassifierDelegateTest, IgnorePreliminaryCapture) { 367 TEST_F(PhishingClassifierDelegateTest, IgnorePreliminaryCapture) {
375 // Tests that preliminary PageCaptured notifications are ignored. 368 // Tests that preliminary PageCaptured notifications are ignored.
(...skipping 11 matching lines...) Expand all
387 Mock::VerifyAndClearExpectations(classifier); 380 Mock::VerifyAndClearExpectations(classifier);
388 OnStartPhishingDetection(delegate, GURL("http://host.com/")); 381 OnStartPhishingDetection(delegate, GURL("http://host.com/"));
389 string16 page_text = ASCIIToUTF16("phish"); 382 string16 page_text = ASCIIToUTF16("phish");
390 delegate->PageCaptured(&page_text, true); 383 delegate->PageCaptured(&page_text, true);
391 384
392 // Once the non-preliminary capture happens, classification should begin. 385 // Once the non-preliminary capture happens, classification should begin.
393 page_text = ASCIIToUTF16("phish"); 386 page_text = ASCIIToUTF16("phish");
394 { 387 {
395 InSequence s; 388 InSequence s;
396 EXPECT_CALL(*classifier, CancelPendingClassification()); 389 EXPECT_CALL(*classifier, CancelPendingClassification());
397 EXPECT_CALL(*classifier, BeginClassification(Pointee(page_text), _)). 390 EXPECT_CALL(*classifier, BeginClassification(Pointee(page_text), _));
398 WillOnce(DeleteArg<1>());
399 delegate->PageCaptured(&page_text, false); 391 delegate->PageCaptured(&page_text, false);
400 Mock::VerifyAndClearExpectations(classifier); 392 Mock::VerifyAndClearExpectations(classifier);
401 } 393 }
402 394
403 // The delegate will cancel pending classification on destruction. 395 // The delegate will cancel pending classification on destruction.
404 EXPECT_CALL(*classifier, CancelPendingClassification()); 396 EXPECT_CALL(*classifier, CancelPendingClassification());
405 } 397 }
406 398
407 TEST_F(PhishingClassifierDelegateTest, DuplicatePageCapture) { 399 TEST_F(PhishingClassifierDelegateTest, DuplicatePageCapture) {
408 // Tests that a second PageCaptured notification causes classification to 400 // Tests that a second PageCaptured notification causes classification to
409 // be cancelled. 401 // be cancelled.
410 MockPhishingClassifier* classifier = 402 MockPhishingClassifier* classifier =
411 new StrictMock<MockPhishingClassifier>(view()); 403 new StrictMock<MockPhishingClassifier>(view());
412 PhishingClassifierDelegate* delegate = 404 PhishingClassifierDelegate* delegate =
413 PhishingClassifierDelegate::Create(view(), classifier); 405 PhishingClassifierDelegate::Create(view(), classifier);
414 MockScorer scorer; 406 MockScorer scorer;
415 delegate->SetPhishingScorer(&scorer); 407 delegate->SetPhishingScorer(&scorer);
416 ASSERT_TRUE(classifier->is_ready()); 408 ASSERT_TRUE(classifier->is_ready());
417 409
418 EXPECT_CALL(*classifier, CancelPendingClassification()); 410 EXPECT_CALL(*classifier, CancelPendingClassification());
419 responses_["http://host.com/"] = "<html><body>phish</body></html>"; 411 responses_["http://host.com/"] = "<html><body>phish</body></html>";
420 LoadURL("http://host.com/"); 412 LoadURL("http://host.com/");
421 Mock::VerifyAndClearExpectations(classifier); 413 Mock::VerifyAndClearExpectations(classifier);
422 OnStartPhishingDetection(delegate, GURL("http://host.com/")); 414 OnStartPhishingDetection(delegate, GURL("http://host.com/"));
423 string16 page_text = ASCIIToUTF16("phish"); 415 string16 page_text = ASCIIToUTF16("phish");
424 { 416 {
425 InSequence s; 417 InSequence s;
426 EXPECT_CALL(*classifier, CancelPendingClassification()); 418 EXPECT_CALL(*classifier, CancelPendingClassification());
427 EXPECT_CALL(*classifier, BeginClassification(Pointee(page_text), _)). 419 EXPECT_CALL(*classifier, BeginClassification(Pointee(page_text), _));
428 WillOnce(DeleteArg<1>());
429 delegate->PageCaptured(&page_text, false); 420 delegate->PageCaptured(&page_text, false);
430 Mock::VerifyAndClearExpectations(classifier); 421 Mock::VerifyAndClearExpectations(classifier);
431 } 422 }
432 423
433 page_text = ASCIIToUTF16("phish"); 424 page_text = ASCIIToUTF16("phish");
434 EXPECT_CALL(*classifier, CancelPendingClassification()); 425 EXPECT_CALL(*classifier, CancelPendingClassification());
435 delegate->PageCaptured(&page_text, false); 426 delegate->PageCaptured(&page_text, false);
436 Mock::VerifyAndClearExpectations(classifier); 427 Mock::VerifyAndClearExpectations(classifier);
437 428
438 // The delegate will cancel pending classification on destruction. 429 // The delegate will cancel pending classification on destruction.
(...skipping 14 matching lines...) Expand all
453 // Start by loading a page to populate the delegate's state. 444 // Start by loading a page to populate the delegate's state.
454 responses_["http://host.com/"] = "<html><body>phish</body></html>"; 445 responses_["http://host.com/"] = "<html><body>phish</body></html>";
455 EXPECT_CALL(*classifier, CancelPendingClassification()); 446 EXPECT_CALL(*classifier, CancelPendingClassification());
456 LoadURL("http://host.com/#a"); 447 LoadURL("http://host.com/#a");
457 Mock::VerifyAndClearExpectations(classifier); 448 Mock::VerifyAndClearExpectations(classifier);
458 string16 page_text = ASCIIToUTF16("phish"); 449 string16 page_text = ASCIIToUTF16("phish");
459 OnStartPhishingDetection(delegate, GURL("http://host.com/#a")); 450 OnStartPhishingDetection(delegate, GURL("http://host.com/#a"));
460 { 451 {
461 InSequence s; 452 InSequence s;
462 EXPECT_CALL(*classifier, CancelPendingClassification()); 453 EXPECT_CALL(*classifier, CancelPendingClassification());
463 EXPECT_CALL(*classifier, BeginClassification(Pointee(page_text), _)). 454 EXPECT_CALL(*classifier, BeginClassification(Pointee(page_text), _));
464 WillOnce(DeleteArg<1>());
465 delegate->PageCaptured(&page_text, false); 455 delegate->PageCaptured(&page_text, false);
466 Mock::VerifyAndClearExpectations(classifier); 456 Mock::VerifyAndClearExpectations(classifier);
467 } 457 }
468 458
469 // Now run the callback to simulate the classifier finishing. 459 // Now run the callback to simulate the classifier finishing.
470 ClientPhishingRequest verdict; 460 ClientPhishingRequest verdict;
471 verdict.set_url("http://host.com/#a"); 461 verdict.set_url("http://host.com/#a");
472 verdict.set_client_score(0.8f); 462 verdict.set_client_score(0.8f);
473 verdict.set_is_phishing(false); // Send IPC even if site is not phishing. 463 verdict.set_is_phishing(false); // Send IPC even if site is not phishing.
474 RunClassificationDone(delegate, verdict); 464 RunClassificationDone(delegate, verdict);
475 ASSERT_TRUE(verdict_.get()); 465 ASSERT_TRUE(verdict_.get());
476 EXPECT_EQ(verdict.SerializeAsString(), verdict_->SerializeAsString()); 466 EXPECT_EQ(verdict.SerializeAsString(), verdict_->SerializeAsString());
477 467
478 // The delegate will cancel pending classification on destruction. 468 // The delegate will cancel pending classification on destruction.
479 EXPECT_CALL(*classifier, CancelPendingClassification()); 469 EXPECT_CALL(*classifier, CancelPendingClassification());
480 } 470 }
481 471
482 } // namespace safe_browsing 472 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698