Commit 1a4c34c5 authored by Toby Huang's avatar Toby Huang Committed by Commit Bot

Add UMATest to AddSupervisionBrowserTest

Add a browser test that ensures the kCompleted UMA metric is being
recorded correctly after executing javascript commands simulating
supervision being enabled.

Bug: 982543
Change-Id: I30caa56c67103801bbbfc453c176dd13d1d87b06
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1804494Reviewed-by: default avatarMichael Giuffrida <michaelpg@chromium.org>
Commit-Queue: Toby Huang <tobyhuang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#696897}
parent 8ac243bc
...@@ -204,6 +204,39 @@ IN_PROC_BROWSER_TEST_F(AddSupervisionBrowserTest, ...@@ -204,6 +204,39 @@ IN_PROC_BROWSER_TEST_F(AddSupervisionBrowserTest,
ASSERT_TRUE(ConfirmSignoutDialog::IsShowing()); ASSERT_TRUE(ConfirmSignoutDialog::IsShowing());
} }
IN_PROC_BROWSER_TEST_F(AddSupervisionBrowserTest, UMATest) {
base::HistogramTester histogram_tester;
base::UserActionTester user_action_tester;
// Should see 0 Add Supervision enrollment metrics at first.
histogram_tester.ExpectTotalCount("AddSupervisionDialog.Enrollment", 0);
// Should see 0 user actions at first.
EXPECT_EQ(user_action_tester.GetActionCount(
"AddSupervisionDialog_AttemptedSignoutAfterEnrollment"),
0);
// Open the Add Supervision URL.
ui_test_utils::NavigateToURL(browser(), add_supervision_webui_url());
content::WaitForLoadStop(contents());
// Simulate supervision being enabled.
ASSERT_TRUE(content::ExecuteScript(
contents(), std::string(kGetAddSupervisionUIElementJS) +
std::string(".server.notifySupervisionEnabled()")));
// Should see 1 Add Supervision process completed.
histogram_tester.ExpectUniqueSample(
"AddSupervisionDialog.Enrollment",
AddSupervisionMetricsRecorder::EnrollmentState::kCompleted, 1);
histogram_tester.ExpectTotalCount("AddSupervisionDialog.Enrollment", 1);
// Should see 1 EnrollmentCompleted action.
EXPECT_EQ(user_action_tester.GetActionCount(
"AddSupervisionDialog_EnrollmentCompleted"),
1);
}
#endif // !defined(MEMORY_SANITIZER) #endif // !defined(MEMORY_SANITIZER)
} // namespace chromeos } // namespace chromeos
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment