OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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/browser/safe_browsing/permission_reporter.h" | 5 #include "chrome/browser/safe_browsing/permission_reporter.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 } | 80 } |
81 | 81 |
82 private: | 82 private: |
83 // Owned by permission reporter. | 83 // Owned by permission reporter. |
84 MockPermissionReportSender* mock_report_sender_; | 84 MockPermissionReportSender* mock_report_sender_; |
85 | 85 |
86 DISALLOW_COPY_AND_ASSIGN(PermissionReporterBrowserTest); | 86 DISALLOW_COPY_AND_ASSIGN(PermissionReporterBrowserTest); |
87 }; | 87 }; |
88 | 88 |
89 // Test that permission action report will be sent if the user is opted into it. | 89 // Test that permission action report will be sent if the user is opted into it. |
90 // TODO(kcarattini): Address crbug/638316 to reenable this test. | |
91 IN_PROC_BROWSER_TEST_F(PermissionReporterBrowserTest, | 90 IN_PROC_BROWSER_TEST_F(PermissionReporterBrowserTest, |
92 DISABLED_PermissionActionReporting) { | 91 PermissionActionReporting) { |
93 // Set up the Sync client. | 92 // Set up the Sync client. |
94 ASSERT_TRUE(SetupSync()); | 93 ASSERT_TRUE(SetupSync()); |
95 Profile* profile = GetProfile(0); | 94 Profile* profile = GetProfile(0); |
96 Browser* browser = CreateBrowser(profile); | 95 Browser* browser = CreateBrowser(profile); |
97 | 96 |
98 // Set up mock permission manager and prompt factory. | 97 // Set up mock permission manager and prompt factory. |
99 PermissionRequestManager* manager = GetPermissionRequestManager(browser); | 98 PermissionRequestManager* manager = GetPermissionRequestManager(browser); |
100 std::unique_ptr<MockPermissionPromptFactory> mock_permission_prompt_factory = | 99 std::unique_ptr<MockPermissionPromptFactory> mock_permission_prompt_factory = |
101 base::MakeUnique<MockPermissionPromptFactory>(manager); | 100 base::MakeUnique<MockPermissionPromptFactory>(manager); |
102 manager->DisplayPendingRequests(); | 101 manager->DisplayPendingRequests(); |
103 | 102 |
104 ASSERT_TRUE(embedded_test_server()->Start()); | 103 ASSERT_TRUE(embedded_test_server()->Start()); |
105 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete( | 104 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete( |
106 browser, embedded_test_server()->GetURL("/permissions/request.html"), | 105 browser, embedded_test_server()->GetURL("/permissions/request.html"), |
107 1); | 106 1); |
108 | 107 |
109 mock_permission_prompt_factory->WaitForPermissionBubble(); | 108 mock_permission_prompt_factory->WaitForPermissionBubble(); |
110 EXPECT_TRUE(mock_permission_prompt_factory->is_visible()); | 109 EXPECT_TRUE(mock_permission_prompt_factory->is_visible()); |
111 | 110 |
112 AcceptBubble(browser); | 111 AcceptBubble(browser); |
| 112 EXPECT_FALSE(mock_permission_prompt_factory->is_visible()); |
113 | 113 |
114 EXPECT_FALSE(mock_permission_prompt_factory->is_visible()); | 114 // We need to wait for the report to be sent on the IO thread. |
| 115 mock_report_sender()->WaitForReportSent(); |
115 EXPECT_EQ(1, mock_report_sender()->GetAndResetNumberOfReportsSent()); | 116 EXPECT_EQ(1, mock_report_sender()->GetAndResetNumberOfReportsSent()); |
116 | 117 |
117 PermissionReport permission_report; | 118 PermissionReport permission_report; |
118 ASSERT_TRUE( | 119 ASSERT_TRUE( |
119 permission_report.ParseFromString(mock_report_sender()->latest_report())); | 120 permission_report.ParseFromString(mock_report_sender()->latest_report())); |
120 EXPECT_EQ(PermissionReport::GEOLOCATION, permission_report.permission()); | 121 EXPECT_EQ(PermissionReport::GEOLOCATION, permission_report.permission()); |
121 EXPECT_EQ(PermissionReport::GRANTED, permission_report.action()); | 122 EXPECT_EQ(PermissionReport::GRANTED, permission_report.action()); |
122 EXPECT_EQ(embedded_test_server()->base_url().spec(), | 123 EXPECT_EQ(embedded_test_server()->base_url().spec(), |
123 permission_report.origin()); | 124 permission_report.origin()); |
124 EXPECT_EQ(PermissionReport::DESKTOP_PLATFORM, | 125 EXPECT_EQ(PermissionReport::DESKTOP_PLATFORM, |
125 permission_report.platform_type()); | 126 permission_report.platform_type()); |
126 EXPECT_EQ(PermissionReport::NO_GESTURE, permission_report.gesture()); | 127 EXPECT_EQ(PermissionReport::NO_GESTURE, permission_report.gesture()); |
127 EXPECT_EQ(PermissionReport::PERSIST_DECISION_UNSPECIFIED, | 128 EXPECT_EQ(PermissionReport::PERSIST_DECISION_UNSPECIFIED, |
128 permission_report.persisted()); | 129 permission_report.persisted()); |
129 EXPECT_EQ(0, permission_report.num_prior_dismissals()); | 130 EXPECT_EQ(0, permission_report.num_prior_dismissals()); |
130 EXPECT_EQ(0, permission_report.num_prior_ignores()); | 131 EXPECT_EQ(0, permission_report.num_prior_ignores()); |
131 } | 132 } |
132 | 133 |
133 } // namespace safe_browsing | 134 } // namespace safe_browsing |
OLD | NEW |