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

Side by Side Diff: chrome/browser/safe_browsing/permission_reporter_browsertest.cc

Issue 2276253002: Permission Action Reporting: Test num_prior* metrics are recorded correctly. (Closed)
Patch Set: Fix typo 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 permission_report.origin()); 124 permission_report.origin());
125 EXPECT_EQ(PermissionReport::DESKTOP_PLATFORM, 125 EXPECT_EQ(PermissionReport::DESKTOP_PLATFORM,
126 permission_report.platform_type()); 126 permission_report.platform_type());
127 EXPECT_EQ(PermissionReport::NO_GESTURE, permission_report.gesture()); 127 EXPECT_EQ(PermissionReport::NO_GESTURE, permission_report.gesture());
128 EXPECT_EQ(PermissionReport::PERSIST_DECISION_UNSPECIFIED, 128 EXPECT_EQ(PermissionReport::PERSIST_DECISION_UNSPECIFIED,
129 permission_report.persisted()); 129 permission_report.persisted());
130 EXPECT_EQ(0, permission_report.num_prior_dismissals()); 130 EXPECT_EQ(0, permission_report.num_prior_dismissals());
131 EXPECT_EQ(0, permission_report.num_prior_ignores()); 131 EXPECT_EQ(0, permission_report.num_prior_ignores());
132 } 132 }
133 133
134 IN_PROC_BROWSER_TEST_F(PermissionReporterBrowserTest,
135 PermissionActionReportingPriorIgnoreCount) {
136 // Set up the Sync client.
137 ASSERT_TRUE(SetupSync());
138 Profile* profile = GetProfile(0);
139 Browser* browser = CreateBrowser(profile);
140
141 // Set up mock permission manager and prompt factory.
142 PermissionRequestManager* manager = GetPermissionRequestManager(browser);
143 std::unique_ptr<MockPermissionPromptFactory> mock_permission_prompt_factory =
144 base::MakeUnique<MockPermissionPromptFactory>(manager);
145 manager->DisplayPendingRequests();
146
147 ASSERT_TRUE(embedded_test_server()->Start());
148 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete(
149 browser, embedded_test_server()->GetURL("/permissions/request.html"),
150 1);
151
152 mock_permission_prompt_factory->WaitForPermissionBubble();
153 EXPECT_TRUE(mock_permission_prompt_factory->is_visible());
154
155 // Ignore this prompt and navigate away.
156 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete(
157 browser, embedded_test_server()->GetURL("/permissions/request.html"),
158 1);
159
160 mock_permission_prompt_factory->WaitForPermissionBubble();
161 EXPECT_TRUE(mock_permission_prompt_factory->is_visible());
162
163 // We don't need to call mock_report_sender()->WaitForReportSent() here
164 // because the report has already been sent during the second call to
165 // NavigateToURLBlockUntilNavigationsComplete().
166 EXPECT_EQ(1, mock_report_sender()->GetAndResetNumberOfReportsSent());
167
168 PermissionReport permission_report;
169 ASSERT_TRUE(
170 permission_report.ParseFromString(mock_report_sender()->latest_report()));
171 EXPECT_EQ(PermissionReport::GEOLOCATION, permission_report.permission());
172 EXPECT_EQ(PermissionReport::IGNORED, permission_report.action());
173 EXPECT_EQ(embedded_test_server()->base_url().spec(),
174 permission_report.origin());
175 EXPECT_EQ(PermissionReport::DESKTOP_PLATFORM,
Nathan Parker 2016/09/01 18:58:50 This got me thinking... are browser tests run on A
176 permission_report.platform_type());
177 EXPECT_EQ(PermissionReport::NO_GESTURE, permission_report.gesture());
178 EXPECT_EQ(PermissionReport::PERSIST_DECISION_UNSPECIFIED,
179 permission_report.persisted());
180 EXPECT_EQ(0, permission_report.num_prior_dismissals());
181 EXPECT_EQ(0, permission_report.num_prior_ignores());
182
183 // Now accept the prompt.
184 AcceptBubble(browser);
185
186 EXPECT_FALSE(mock_permission_prompt_factory->is_visible());
187 mock_report_sender()->WaitForReportSent();
188 EXPECT_EQ(1, mock_report_sender()->GetAndResetNumberOfReportsSent());
189
190 ASSERT_TRUE(
191 permission_report.ParseFromString(mock_report_sender()->latest_report()));
192 EXPECT_EQ(PermissionReport::GEOLOCATION, permission_report.permission());
193 EXPECT_EQ(PermissionReport::GRANTED, permission_report.action());
194 EXPECT_EQ(embedded_test_server()->base_url().spec(),
195 permission_report.origin());
196 EXPECT_EQ(PermissionReport::DESKTOP_PLATFORM,
197 permission_report.platform_type());
198 EXPECT_EQ(PermissionReport::NO_GESTURE, permission_report.gesture());
199 EXPECT_EQ(PermissionReport::PERSIST_DECISION_UNSPECIFIED,
200 permission_report.persisted());
201 EXPECT_EQ(0, permission_report.num_prior_dismissals());
202 // Ensure that we correctly record one prior ignore.
203 EXPECT_EQ(1, permission_report.num_prior_ignores());
204 }
205
134 } // namespace safe_browsing 206 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698