Commit 4023b8b6 authored by Caitlin Fischer's avatar Caitlin Fischer Committed by Commit Bot

Remove a UKM test that should have been deleted.

In the below comment, it was requested that the corresponding Android
test be removed.
https://chromium-review.googlesource.com/c/chromium/src/+/1869007/12/chrome/browser/metrics/ukm_browsertest.cc#b646

Bug: 1049736
Change-Id: Iac3ff27fc4d8145bef53d45aecb54efeda5e55f6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2245049
Commit-Queue: Caitlin Fischer <caitlinfischer@google.com>
Reviewed-by: default avatarRobert Kaplow <rkaplow@chromium.org>
Reviewed-by: default avatarMarc Treib <treib@chromium.org>
Cr-Commit-Position: refs/heads/master@{#779285}
parent 62b3363e
......@@ -502,7 +502,6 @@ chrome_test_java_sources = [
"javatests/src/org/chromium/chrome/browser/sync/SyncTest.java",
"javatests/src/org/chromium/chrome/browser/sync/SyncTestRule.java",
"javatests/src/org/chromium/chrome/browser/sync/TypedUrlsTest.java",
"javatests/src/org/chromium/chrome/browser/sync/UkmTest.java",
"javatests/src/org/chromium/chrome/browser/sync/ui/PassphraseActivityTest.java",
"javatests/src/org/chromium/chrome/browser/sync/ui/PassphraseTypeDialogFragmentTest.java",
"javatests/src/org/chromium/chrome/browser/tab/InterceptNavigationDelegateTest.java",
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.chrome.browser.sync;
import android.accounts.Account;
import androidx.test.filters.SmallTest;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.chromium.base.test.util.CommandLineFlags;
import org.chromium.chrome.browser.flags.ChromeSwitches;
import org.chromium.chrome.browser.metrics.UmaSessionStats;
import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
import org.chromium.components.sync.ModelType;
import org.chromium.content_public.browser.test.util.JavaScriptUtils;
import org.chromium.content_public.browser.test.util.TestThreadUtils;
import org.chromium.ui.base.PageTransition;
/**
* Tests for UKM Sync integration.
*/
@RunWith(ChromeJUnit4ClassRunner.class)
@CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE})
// Note we do not use the 'force-enable-metrics-reporting' flag for these tests as they would
// ignore the Sync setting we are verifying.
public class UkmTest {
@Rule
public SyncTestRule mSyncTestRule = new SyncTestRule();
private static final String DEBUG_PAGE = "chrome://ukm/";
@Before
public void setUp() throws InterruptedException {
mSyncTestRule.startMainActivityOnBlankPage();
TestThreadUtils.runOnUiThreadBlocking(
() -> UmaSessionStats.initMetricsAndCrashReportingForTesting());
}
@After
public void tearDown() {
TestThreadUtils.runOnUiThreadBlocking(
() -> UmaSessionStats.unSetMetricsAndCrashReportingForTesting());
}
public String getElementContent(Tab normalTab, String elementId) throws Exception {
mSyncTestRule.loadUrlInTab(
DEBUG_PAGE, PageTransition.TYPED | PageTransition.FROM_ADDRESS_BAR, normalTab);
return JavaScriptUtils.executeJavaScriptAndWaitForResult(normalTab.getWebContents(),
"document.getElementById('" + elementId + "').textContent");
}
public boolean isUkmEnabled(Tab normalTab) throws Exception {
String state = getElementContent(normalTab, "state");
Assert.assertTrue(
"UKM state: " + state, state.equals("\"ENABLED\"") || state.equals("\"DISABLED\""));
return state.equals("\"ENABLED\"");
}
public String getUkmClientId(Tab normalTab) throws Exception {
return getElementContent(normalTab, "clientid");
}
@Test
@SmallTest
// TODO(crbug/1049736): Enable the corrersponding C++ test and delete this
// test.
public void singleDisableHistorySyncCheck() throws Exception {
// Keep in sync with UkmBrowserTest.SingleDisableHistorySyncCheck in
// chrome/browser/metrics/ukm_browsertest.cc.
// Make sure that UKM is disabled when an secondary passphrase is set.
TestThreadUtils.runOnUiThreadBlocking(
() -> UmaSessionStats.updateMetricsAndCrashReportingForTesting(true));
// Enable a Syncing account.
Account account = mSyncTestRule.setUpAccountAndSignInForTesting();
Tab normalTab = mSyncTestRule.getActivity().getActivityTab();
Assert.assertTrue("UKM Enabled:", isUkmEnabled(normalTab));
String originalClientId = getUkmClientId(normalTab);
// Disable Sync for history.
mSyncTestRule.disableDataType(ModelType.TYPED_URLS);
// Disable history sync does not disable UKM
Assert.assertTrue("UKM Enabled:", isUkmEnabled(normalTab));
}
}
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