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

Side by Side Diff: chrome/browser/plugins/flash_download_interception_unittest.cc

Issue 2272123002: [HBD] Intercept navigation to Flash download page (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changes per clamy@'s comment Created 4 years, 3 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 | « chrome/browser/plugins/flash_download_interception.cc ('k') | chrome/chrome_tests_unit.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/plugins/flash_download_interception.h"
6
7 #include "base/test/scoped_feature_list.h"
8 #include "chrome/common/chrome_features.h"
9 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
10 #include "content/public/browser/navigation_handle.h"
11 #include "testing/gtest/include/gtest/gtest.h"
12 #include "url/gurl.h"
13
14 using content::NavigationHandle;
15 using content::NavigationThrottle;
16
17 class FlashDownloadInterceptionTest : public ChromeRenderViewHostTestHarness {
18 public:
19 FlashDownloadInterceptionTest() {}
20
21 void SetUp() override {
22 ChromeRenderViewHostTestHarness::SetUp();
23 flash_navigation_handle_ =
24 NavigationHandle::CreateNavigationHandleForTesting(
25 GURL("https://get.adobe.com/flashplayer"), main_rfh());
26 flash_slash_navigation_handle_ =
27 NavigationHandle::CreateNavigationHandleForTesting(
28 GURL("https://get.adobe.com/flashplayer/"), main_rfh());
Lei Zhang 2016/09/01 21:08:11 Maybe also try: http://get.adobe.com/flashplayer
trizzofo 2016/09/01 21:30:28 Done.
29 example_navigation_handle_ =
30 NavigationHandle::CreateNavigationHandleForTesting(
31 GURL("https://www.example.com"), main_rfh());
32 }
33
34 void TearDown() override {
35 flash_navigation_handle_.reset();
36 flash_slash_navigation_handle_.reset();
37 example_navigation_handle_.reset();
38 ChromeRenderViewHostTestHarness::TearDown();
39 }
40
41 protected:
42 std::unique_ptr<NavigationHandle> flash_navigation_handle_;
43 std::unique_ptr<NavigationHandle> flash_slash_navigation_handle_;
Lei Zhang 2016/09/01 21:08:11 Can the two that are only used in a single test be
trizzofo 2016/09/01 21:30:28 Done.
44 std::unique_ptr<NavigationHandle> example_navigation_handle_;
45 };
46
47 TEST_F(FlashDownloadInterceptionTest, PreferHtmlOverPluginsOff) {
48 base::test::ScopedFeatureList feature_list;
49 feature_list.InitAndDisableFeature(features::kPreferHtmlOverPlugins);
50
51 flash_navigation_handle_->CallWillStartRequestForTesting(
52 true, content::Referrer(), true, ui::PAGE_TRANSITION_LINK, false);
53 std::unique_ptr<NavigationThrottle> throttle =
54 FlashDownloadInterception::MaybeCreateThrottleFor(
55 flash_navigation_handle_.get());
56 EXPECT_EQ(nullptr, throttle);
57 }
58
59 TEST_F(FlashDownloadInterceptionTest, PreferHtmlOverPluginsOn) {
60 std::unique_ptr<NavigationThrottle> throttle;
61 base::test::ScopedFeatureList feature_list;
62 feature_list.InitAndEnableFeature(features::kPreferHtmlOverPlugins);
63
64 flash_navigation_handle_->CallWillStartRequestForTesting(
65 true, content::Referrer(), false, ui::PAGE_TRANSITION_LINK, false);
66 throttle = FlashDownloadInterception::MaybeCreateThrottleFor(
67 flash_navigation_handle_.get());
68 EXPECT_EQ(nullptr, throttle);
69
70 flash_navigation_handle_->CallWillStartRequestForTesting(
71 true, content::Referrer(), true, ui::PAGE_TRANSITION_LINK, false);
72 throttle = FlashDownloadInterception::MaybeCreateThrottleFor(
73 flash_navigation_handle_.get());
74 EXPECT_NE(nullptr, throttle);
75 ASSERT_EQ(NavigationThrottle::CANCEL_AND_IGNORE,
76 throttle->WillStartRequest());
77
78 flash_slash_navigation_handle_->CallWillStartRequestForTesting(
79 true, content::Referrer(), true, ui::PAGE_TRANSITION_LINK, false);
80 throttle = FlashDownloadInterception::MaybeCreateThrottleFor(
81 flash_navigation_handle_.get());
82 EXPECT_NE(nullptr, throttle);
83 ASSERT_EQ(NavigationThrottle::CANCEL_AND_IGNORE,
84 throttle->WillStartRequest());
85
86 example_navigation_handle_->CallWillStartRequestForTesting(
87 true, content::Referrer(), true, ui::PAGE_TRANSITION_LINK, false);
88 throttle = FlashDownloadInterception::MaybeCreateThrottleFor(
89 example_navigation_handle_.get());
90 EXPECT_EQ(nullptr, throttle);
91 }
OLDNEW
« no previous file with comments | « chrome/browser/plugins/flash_download_interception.cc ('k') | chrome/chrome_tests_unit.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698