Commit ecb81c3f authored by Noel Gordon's avatar Noel Gordon Committed by Commit Bot

FilesApp analytics: remove metrics unittest

CL:1347648 removed google analytics from FilesApp so metrics_unittest,
which was disabled on issue 842880, can now be deleted [1].

[1] The metrics_unittest test fixtures required a {analytics.Tracker},
which no longer exists in FilesApp.

Bug: 847729, 860355
Change-Id: I0ec71ef837e747cd6647d7359546b9876d62dbc8
Reviewed-on: https://chromium-review.googlesource.com/c/1355303Reviewed-by: default avatarStuart Langley <slangley@chromium.org>
Commit-Queue: Noel Gordon <noel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#612528}
parent 4cebe24d
......@@ -97,11 +97,6 @@ IN_PROC_BROWSER_TEST_F(FileManagerJsTest, AsyncUtilTest) {
RunGeneratedTest("/common/js/async_util_unittest.html");
}
// TODO(sashab): Re-enable when https://crbug.com/842880 is fixed.
IN_PROC_BROWSER_TEST_F(FileManagerJsTest, DISABLED_MetricsTest) {
RunTest(base::FilePath(FILE_PATH_LITERAL("common/js/metrics_unittest.html")));
}
IN_PROC_BROWSER_TEST_F(FileManagerJsTest, TaskController) {
RunTest(base::FilePath(
FILE_PATH_LITERAL("foreground/js/task_controller_unittest.html")));
......
<!DOCTYPE html>
<!-- Copyright 2015 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.
-->
<html>
<body>
<script src="../../../../../ui/webui/resources/js/assert.js"></script>
<script src="../../../../../ui/webui/resources/js/cr.js"></script>
<script src="../../../../../ui/webui/resources/js/cr/event_target.js"></script>
<script src="../../../../../ui/webui/resources/js/cr/ui/array_data_model.js"></script>
<script src="../../../../../ui/webui/resources/js/load_time_data.js"></script>
<script src="../../../../file_manager/base/js/test_error_reporting.js"></script>
<script src="util.js"></script>
<script src="metrics_base.js"></script>
<script src="metrics.js"></script>
<script src="metrics_unittest.js"></script>
</body>
</html>
// Copyright 2015 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.
// Fake APIs
var chrome;
/** @type {analytics.Tracker.Hit} The last hit received. */
var lastHit = null;
/** @type {!analytics.Tracker} */
var tracker;
function setUp() {
setupFakeChromeAPIs();
// Set a fake tracking ID so the tests aren't actually sending analytics.
metrics.TRACKING_IDS[chrome.runtime.id] = 'UA-XXXXX-XX';
tracker = metrics.getTracker();
// Make a filter that logs the last received hit.
tracker.addFilter(
/** @param {!analytics.Tracker.Hit} hit */
function(hit) {
// Log the hit.
lastHit = hit;
});
// Reset the last logged hit.
lastHit = null;
}
// Verifies that analytics logging occurs when fileManagerPrivate.isUMAEnabled
// returns true.
function testBasicLogging(callback) {
// Simulate UMA enabled, then check that hits are sent.
chrome.fileManagerPrivate.umaEnabled = true;
reportPromise(
tracker.sendAppView('Test').addCallback(
function() {
assertTrue(!!lastHit);
}),
callback);
}
// Verifies that analytics logging does not occur when
// fileManagerPrivate.isUMAEnabled returns false.
function testUMADisabled(callback) {
// Simulate UMA disabled, and verify that hits aren't sent.
chrome.fileManagerPrivate.umaEnabled = false;
reportPromise(
tracker.sendAppView('Test').addCallback(
function() {
assertTrue(lastHit === null);
}),
callback);
}
// Verifies that toggling the UMA setting causes the user's analytics ID to be
// reset.
function testResetAnalyticsOnUMAToggle(callback) {
var id0 = null;
var id1 = null;
// Simulate UMA enabled, and send a hit.
chrome.fileManagerPrivate.umaEnabled = true;
reportPromise(
tracker.sendAppView('Test0')
.then(
function() {
// Log the analytics ID that got sent.
id0 = lastHit.getParameters().toObject()['clientId'];
// Simulate UMA disabled, send another hit.
chrome.fileManagerPrivate.umaEnabled = false;
return tracker.sendAppView('Test1');
})
.then(
function() {
// Re-enable analytics, send another hit.
chrome.fileManagerPrivate.umaEnabled = true;
return tracker.sendAppView('Test2');
})
.then(
function() {
// Check that a subsequent hit has a different analytics ID.
id1 = lastHit.getParameters().toObject()['clientId'];
assertTrue(id0 !== id1);
}),
callback);
}
function setupFakeChromeAPIs() {
chrome = {
runtime: {
getManifest: function() {
return {
version: 0.0
};
}
},
storage: {
local: {
// Analytics uses storage to store the enabled/disabled flag. Hard-wire
// the get method to always return true so analytics is jammed on for
// the purposes of testing.
get: function(data, cb) { cb(true); },
set: function(data, cb) {}
},
onChanged: {
addListener: function(cb) {}
}
},
fileManagerPrivate: {
umaEnabled: false,
isUMAEnabled: function(cb) { cb(chrome.fileManagerPrivate.umaEnabled); }
}
};
}
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