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

Side by Side Diff: components/subresource_filter/content/browser/subresource_filter_safe_browsing_activation_throttle_unittest.cc

Issue 2844063002: Add support for multiple simultaneous subresource_filter::Configurations. (Closed)
Patch Set: Rebase. Created 3 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
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 "components/subresource_filter/content/browser/subresource_filter_safe_ browsing_activation_throttle.h" 5 #include "components/subresource_filter/content/browser/subresource_filter_safe_ browsing_activation_throttle.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <tuple> 8 #include <tuple>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 SubresourceFilterSafeBrowsingActivationThrottleTestWithCancelling); 278 SubresourceFilterSafeBrowsingActivationThrottleTestWithCancelling);
279 }; 279 };
280 280
281 TEST_F(SubresourceFilterSafeBrowsingActivationThrottleTest, 281 TEST_F(SubresourceFilterSafeBrowsingActivationThrottleTest,
282 ListNotMatched_NoActivation) { 282 ListNotMatched_NoActivation) {
283 const GURL url(kURL); 283 const GURL url(kURL);
284 CreateTestNavigationForMainFrame(url); 284 CreateTestNavigationForMainFrame(url);
285 SimulateStartAndExpectProceed(); 285 SimulateStartAndExpectProceed();
286 SimulateCommitAndExpectProceed(); 286 SimulateCommitAndExpectProceed();
287 EXPECT_EQ(ContentSubresourceFilterDriverFactory::ActivationDecision:: 287 EXPECT_EQ(ContentSubresourceFilterDriverFactory::ActivationDecision::
288 ACTIVATION_LIST_NOT_MATCHED, 288 ACTIVATION_CONDITIONS_NOT_MET,
289 factory()->GetActivationDecisionForLastCommittedPageLoad()); 289 factory()->GetActivationDecisionForLastCommittedPageLoad());
290 tester().ExpectTotalCount(kMatchesPatternHistogramNameSubresourceFilterSuffix, 290 tester().ExpectTotalCount(kMatchesPatternHistogramNameSubresourceFilterSuffix,
291 0); 291 0);
292 tester().ExpectTotalCount(kNavigationChainSizeSubresourceFilterSuffix, 0); 292 tester().ExpectTotalCount(kNavigationChainSizeSubresourceFilterSuffix, 0);
293 tester().ExpectTotalCount(kSafeBrowsingNavigationDelay, 1); 293 tester().ExpectTotalCount(kSafeBrowsingNavigationDelay, 1);
294 tester().ExpectTotalCount(kSafeBrowsingNavigationDelayNoSpeculation, 1); 294 tester().ExpectTotalCount(kSafeBrowsingNavigationDelayNoSpeculation, 1);
295 tester().ExpectTotalCount(kSafeBrowsingCheckTime, 1); 295 tester().ExpectTotalCount(kSafeBrowsingCheckTime, 1);
296 } 296 }
297 297
298 TEST_F(SubresourceFilterSafeBrowsingActivationThrottleTest, 298 TEST_F(SubresourceFilterSafeBrowsingActivationThrottleTest,
(...skipping 13 matching lines...) Expand all
312 } 312 }
313 313
314 TEST_F(SubresourceFilterSafeBrowsingActivationThrottleTest, 314 TEST_F(SubresourceFilterSafeBrowsingActivationThrottleTest,
315 ListNotMatchedAfterRedirect_NoActivation) { 315 ListNotMatchedAfterRedirect_NoActivation) {
316 const GURL url(kURL); 316 const GURL url(kURL);
317 CreateTestNavigationForMainFrame(url); 317 CreateTestNavigationForMainFrame(url);
318 SimulateStartAndExpectProceed(); 318 SimulateStartAndExpectProceed();
319 SimulateRedirectAndExpectProceed(GURL(kRedirectURL)); 319 SimulateRedirectAndExpectProceed(GURL(kRedirectURL));
320 SimulateCommitAndExpectProceed(); 320 SimulateCommitAndExpectProceed();
321 EXPECT_EQ(ContentSubresourceFilterDriverFactory::ActivationDecision:: 321 EXPECT_EQ(ContentSubresourceFilterDriverFactory::ActivationDecision::
322 ACTIVATION_LIST_NOT_MATCHED, 322 ACTIVATION_CONDITIONS_NOT_MET,
323 factory()->GetActivationDecisionForLastCommittedPageLoad()); 323 factory()->GetActivationDecisionForLastCommittedPageLoad());
324 tester().ExpectTotalCount(kMatchesPatternHistogramNameSubresourceFilterSuffix, 324 tester().ExpectTotalCount(kMatchesPatternHistogramNameSubresourceFilterSuffix,
325 0); 325 0);
326 tester().ExpectTotalCount(kNavigationChainSizeSubresourceFilterSuffix, 0); 326 tester().ExpectTotalCount(kNavigationChainSizeSubresourceFilterSuffix, 0);
327 } 327 }
328 328
329 TEST_F(SubresourceFilterSafeBrowsingActivationThrottleTest, 329 TEST_F(SubresourceFilterSafeBrowsingActivationThrottleTest,
330 ListMatchedAfterRedirect_Activation) { 330 ListMatchedAfterRedirect_Activation) {
331 const GURL url(kURL); 331 const GURL url(kURL);
332 ConfigureAsSubresourceFilterOnlyURL(GURL(kRedirectURL)); 332 ConfigureAsSubresourceFilterOnlyURL(GURL(kRedirectURL));
(...skipping 21 matching lines...) Expand all
354 // posted. 354 // posted.
355 test_io_task_runner()->RunUntilIdle(); 355 test_io_task_runner()->RunUntilIdle();
356 356
357 // Expect one delayed task, and fast forward time. 357 // Expect one delayed task, and fast forward time.
358 base::TimeDelta expected_delay = 358 base::TimeDelta expected_delay =
359 SubresourceFilterSafeBrowsingClientRequest::kCheckURLTimeout; 359 SubresourceFilterSafeBrowsingClientRequest::kCheckURLTimeout;
360 EXPECT_EQ(expected_delay, test_io_task_runner()->NextPendingTaskDelay()); 360 EXPECT_EQ(expected_delay, test_io_task_runner()->NextPendingTaskDelay());
361 test_io_task_runner()->FastForwardBy(expected_delay); 361 test_io_task_runner()->FastForwardBy(expected_delay);
362 SimulateCommitAndExpectProceed(); 362 SimulateCommitAndExpectProceed();
363 EXPECT_EQ(ContentSubresourceFilterDriverFactory::ActivationDecision:: 363 EXPECT_EQ(ContentSubresourceFilterDriverFactory::ActivationDecision::
364 ACTIVATION_LIST_NOT_MATCHED, 364 ACTIVATION_CONDITIONS_NOT_MET,
365 factory()->GetActivationDecisionForLastCommittedPageLoad()); 365 factory()->GetActivationDecisionForLastCommittedPageLoad());
366 tester().ExpectTotalCount(kMatchesPatternHistogramNameSubresourceFilterSuffix, 366 tester().ExpectTotalCount(kMatchesPatternHistogramNameSubresourceFilterSuffix,
367 0); 367 0);
368 tester().ExpectTotalCount(kNavigationChainSizeSubresourceFilterSuffix, 0); 368 tester().ExpectTotalCount(kNavigationChainSizeSubresourceFilterSuffix, 0);
369 tester().ExpectTotalCount(kSafeBrowsingNavigationDelay, 1); 369 tester().ExpectTotalCount(kSafeBrowsingNavigationDelay, 1);
370 tester().ExpectTotalCount(kSafeBrowsingNavigationDelayNoSpeculation, 1); 370 tester().ExpectTotalCount(kSafeBrowsingNavigationDelayNoSpeculation, 1);
371 tester().ExpectTotalCount(kSafeBrowsingCheckTime, 1); 371 tester().ExpectTotalCount(kSafeBrowsingCheckTime, 1);
372 } 372 }
373 373
374 TEST_F(SubresourceFilterSafeBrowsingActivationThrottleTest, 374 TEST_F(SubresourceFilterSafeBrowsingActivationThrottleTest,
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 // These two lines also test how the database client reacts to two requests 431 // These two lines also test how the database client reacts to two requests
432 // happening one after another. 432 // happening one after another.
433 SimulateStartAndExpectProceed(); 433 SimulateStartAndExpectProceed();
434 SimulateRedirectAndExpectProceed(redirect_url); 434 SimulateRedirectAndExpectProceed(redirect_url);
435 435
436 // Get the database result back before commit. 436 // Get the database result back before commit.
437 RunUntilIdle(); 437 RunUntilIdle();
438 438
439 SimulateCommitAndExpectProceed(); 439 SimulateCommitAndExpectProceed();
440 EXPECT_EQ(ContentSubresourceFilterDriverFactory::ActivationDecision:: 440 EXPECT_EQ(ContentSubresourceFilterDriverFactory::ActivationDecision::
441 ACTIVATION_LIST_NOT_MATCHED, 441 ACTIVATION_CONDITIONS_NOT_MET,
442 factory()->GetActivationDecisionForLastCommittedPageLoad()); 442 factory()->GetActivationDecisionForLastCommittedPageLoad());
443 tester().ExpectTotalCount(kMatchesPatternHistogramNameSubresourceFilterSuffix, 443 tester().ExpectTotalCount(kMatchesPatternHistogramNameSubresourceFilterSuffix,
444 0); 444 0);
445 tester().ExpectTotalCount(kNavigationChainSizeSubresourceFilterSuffix, 0); 445 tester().ExpectTotalCount(kNavigationChainSizeSubresourceFilterSuffix, 0);
446 tester().ExpectTimeBucketCount(kSafeBrowsingNavigationDelay, 446 tester().ExpectTimeBucketCount(kSafeBrowsingNavigationDelay,
447 base::TimeDelta::FromMilliseconds(0), 1); 447 base::TimeDelta::FromMilliseconds(0), 1);
448 tester().ExpectTotalCount(kSafeBrowsingNavigationDelayNoSpeculation, 1); 448 tester().ExpectTotalCount(kSafeBrowsingNavigationDelayNoSpeculation, 1);
449 } 449 }
450 450
451 TEST_P(SubresourceFilterSafeBrowsingActivationThrottleTestWithCancelling, 451 TEST_P(SubresourceFilterSafeBrowsingActivationThrottleTestWithCancelling,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 ::testing::Combine( 487 ::testing::Combine(
488 ::testing::Values( 488 ::testing::Values(
489 content::CancellingNavigationThrottle::WILL_START_REQUEST, 489 content::CancellingNavigationThrottle::WILL_START_REQUEST,
490 content::CancellingNavigationThrottle::WILL_REDIRECT_REQUEST, 490 content::CancellingNavigationThrottle::WILL_REDIRECT_REQUEST,
491 content::CancellingNavigationThrottle::WILL_PROCESS_RESPONSE), 491 content::CancellingNavigationThrottle::WILL_PROCESS_RESPONSE),
492 ::testing::Values( 492 ::testing::Values(
493 content::CancellingNavigationThrottle::SYNCHRONOUS, 493 content::CancellingNavigationThrottle::SYNCHRONOUS,
494 content::CancellingNavigationThrottle::ASYNCHRONOUS))); 494 content::CancellingNavigationThrottle::ASYNCHRONOUS)));
495 495
496 } // namespace subresource_filter 496 } // namespace subresource_filter
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698