Commit 761d890e authored by Andrei-Laurențiu Olteanu's avatar Andrei-Laurențiu Olteanu Committed by Commit Bot

[Telemetry SWX] Add GetAvailableRoutines

Implement GetAvailableRoutines that exposes the same interface from
cros_healthd to chrome-trusted.

Add converters for types used by GetAvailableRoutines.

Bug: b:162051831

Change-Id: I925dc22824a8adb52cc33b3296d80c21ed7d32ff
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2312417Reviewed-by: default avatarMahmoud Gawad <mgawad@google.com>
Reviewed-by: default avatarTom Sepez <tsepez@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Reviewed-by: default avatarGiovanni Ortuño Urquidi <ortuno@chromium.org>
Reviewed-by: default avatarOleh Lamzin <lamzin@google.com>
Commit-Queue: Oleh Lamzin <lamzin@google.com>
Cr-Commit-Position: refs/heads/master@{#794246}
parent 5d32f1de
......@@ -171,6 +171,7 @@
#endif
#if defined(OS_CHROMEOS) && !defined(OFFICIAL_BUILD)
#include "chromeos/components/telemetry_extension_ui/mojom/diagnostics_service.mojom.h"
#include "chromeos/components/telemetry_extension_ui/mojom/probe_service.mojom.h"
#include "chromeos/components/telemetry_extension_ui/telemetry_extension_ui.h"
#endif
......@@ -599,6 +600,9 @@ void PopulateChromeWebUIFrameBinders(
#if defined(OS_CHROMEOS) && !defined(OFFICIAL_BUILD)
if (base::FeatureList::IsEnabled(chromeos::features::kTelemetryExtension)) {
RegisterWebUIControllerInterfaceBinder<
chromeos::health::mojom::DiagnosticsService,
chromeos::TelemetryExtensionUI>(map);
RegisterWebUIControllerInterfaceBinder<
chromeos::health::mojom::ProbeService, chromeos::TelemetryExtensionUI>(
map);
......
......@@ -8,6 +8,10 @@ assert(!is_official_build,
source_set("telemetry_extension_ui") {
sources = [
"diagnostics_service.cc",
"diagnostics_service.h",
"diagnostics_service_converters.cc",
"diagnostics_service_converters.h",
"probe_service.cc",
"probe_service.h",
"probe_service_converters.cc",
......@@ -28,6 +32,7 @@ source_set("telemetry_extension_ui") {
"//chromeos/services/cros_healthd/public/cpp",
"//chromeos/services/cros_healthd/public/mojom",
"//content/public/browser",
"//mojo/public/js:resources",
"//ui/webui",
]
}
......
......@@ -3,6 +3,7 @@ include_rules = [
"+chromeos/grit/chromeos_telemetry_extension_resources.h",
"+content/public/browser",
"+content/public/common",
"+mojo/public/js/grit",
"+ui/base/resource/resource_bundle.h",
"+ui/webui",
]
// Copyright 2020 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.
#include "chromeos/components/telemetry_extension_ui/diagnostics_service.h"
#include <utility>
#include <vector>
#include "base/bind.h"
#include "chromeos/components/telemetry_extension_ui/diagnostics_service_converters.h"
#include "chromeos/services/cros_healthd/public/cpp/service_connection.h"
#include "chromeos/services/cros_healthd/public/mojom/cros_healthd_diagnostics.mojom.h"
namespace chromeos {
DiagnosticsService::DiagnosticsService(
mojo::PendingReceiver<health::mojom::DiagnosticsService> receiver)
: receiver_(this, std::move(receiver)) {}
DiagnosticsService::~DiagnosticsService() = default;
cros_healthd::mojom::CrosHealthdDiagnosticsService*
DiagnosticsService::GetService() {
if (!service_ || !service_.is_connected()) {
cros_healthd::ServiceConnection::GetInstance()->GetDiagnosticsService(
service_.BindNewPipeAndPassReceiver());
service_.set_disconnect_handler(base::BindOnce(
&DiagnosticsService::OnDisconnect, base::Unretained(this)));
}
return service_.get();
}
void DiagnosticsService::OnDisconnect() {
service_.reset();
}
void DiagnosticsService::GetAvailableRoutines(
GetAvailableRoutinesCallback callback) {
GetService()->GetAvailableRoutines(base::BindOnce(
[](health::mojom::DiagnosticsService::GetAvailableRoutinesCallback
callback,
const std::vector<cros_healthd::mojom::DiagnosticRoutineEnum>&
routines) {
std::move(callback).Run(
diagnostics_service_converters::Convert(routines));
},
std::move(callback)));
}
} // namespace chromeos
// Copyright 2020 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.
#ifndef CHROMEOS_COMPONENTS_TELEMETRY_EXTENSION_UI_DIAGNOSTICS_SERVICE_H_
#define CHROMEOS_COMPONENTS_TELEMETRY_EXTENSION_UI_DIAGNOSTICS_SERVICE_H_
#if defined(OFFICIAL_BUILD)
#error Diagnostics service should only be included in unofficial builds.
#endif
#include "chromeos/components/telemetry_extension_ui/mojom/diagnostics_service.mojom.h"
#include "chromeos/services/cros_healthd/public/mojom/cros_healthd.mojom.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h"
namespace chromeos {
class DiagnosticsService : public health::mojom::DiagnosticsService {
public:
explicit DiagnosticsService(
mojo::PendingReceiver<health::mojom::DiagnosticsService> receiver);
DiagnosticsService(const DiagnosticsService&) = delete;
DiagnosticsService& operator=(const DiagnosticsService&) = delete;
~DiagnosticsService() override;
private:
void GetAvailableRoutines(GetAvailableRoutinesCallback callback) override;
// Ensures that |service_| created and connected to the
// CrosHealthdProbeService.
cros_healthd::mojom::CrosHealthdDiagnosticsService* GetService();
void OnDisconnect();
// Pointer to real implementation.
mojo::Remote<cros_healthd::mojom::CrosHealthdDiagnosticsService> service_;
// We must destroy |receiver_| before destroying |service_|, so we will close
// interface pipe before destroying pending response callbacks owned by
// |service_|. It is an error to drop response callbacks which still
// correspond to an open interface pipe.
mojo::Receiver<health::mojom::DiagnosticsService> receiver_;
};
} // namespace chromeos
#endif // CHROMEOS_COMPONENTS_TELEMETRY_EXTENSION_UI_DIAGNOSTICS_SERVICE_H_
// Copyright 2020 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.
#include "chromeos/components/telemetry_extension_ui/diagnostics_service_converters.h"
#include "base/notreached.h"
#include "base/optional.h"
#include "chromeos/components/telemetry_extension_ui/mojom/diagnostics_service.mojom.h"
#include "chromeos/services/cros_healthd/public/mojom/cros_healthd_diagnostics.mojom.h"
namespace chromeos {
namespace diagnostics_service_converters {
namespace {
base::Optional<health::mojom::DiagnosticRoutineEnum> Convert(
cros_healthd::mojom::DiagnosticRoutineEnum input) {
switch (input) {
case cros_healthd::mojom::DiagnosticRoutineEnum::kBatteryCapacity:
return health::mojom::DiagnosticRoutineEnum::kBatteryCapacity;
case cros_healthd::mojom::DiagnosticRoutineEnum::kBatteryHealth:
return health::mojom::DiagnosticRoutineEnum::kBatteryHealth;
case cros_healthd::mojom::DiagnosticRoutineEnum::kUrandom:
return health::mojom::DiagnosticRoutineEnum::kUrandom;
case cros_healthd::mojom::DiagnosticRoutineEnum::kSmartctlCheck:
return health::mojom::DiagnosticRoutineEnum::kSmartctlCheck;
case cros_healthd::mojom::DiagnosticRoutineEnum::kAcPower:
return health::mojom::DiagnosticRoutineEnum::kAcPower;
case cros_healthd::mojom::DiagnosticRoutineEnum::kCpuCache:
return health::mojom::DiagnosticRoutineEnum::kCpuCache;
case cros_healthd::mojom::DiagnosticRoutineEnum::kCpuStress:
return health::mojom::DiagnosticRoutineEnum::kCpuStress;
case cros_healthd::mojom::DiagnosticRoutineEnum::kFloatingPointAccuracy:
return health::mojom::DiagnosticRoutineEnum::kFloatingPointAccuracy;
case cros_healthd::mojom::DiagnosticRoutineEnum::kNvmeWearLevel:
return health::mojom::DiagnosticRoutineEnum::kNvmeWearLevel;
case cros_healthd::mojom::DiagnosticRoutineEnum::kNvmeSelfTest:
return health::mojom::DiagnosticRoutineEnum::kNvmeSelfTest;
case cros_healthd::mojom::DiagnosticRoutineEnum::kDiskRead:
return health::mojom::DiagnosticRoutineEnum::kDiskRead;
case cros_healthd::mojom::DiagnosticRoutineEnum::kPrimeSearch:
return health::mojom::DiagnosticRoutineEnum::kPrimeSearch;
case cros_healthd::mojom::DiagnosticRoutineEnum::kBatteryDischarge:
return health::mojom::DiagnosticRoutineEnum::kBatteryDischarge;
}
NOTREACHED();
return base::nullopt;
}
} // namespace
std::vector<health::mojom::DiagnosticRoutineEnum> Convert(
const std::vector<cros_healthd::mojom::DiagnosticRoutineEnum>& input) {
std::vector<health::mojom::DiagnosticRoutineEnum> output;
for (const auto element : input) {
base::Optional<health::mojom::DiagnosticRoutineEnum> converted =
Convert(element);
if (converted.has_value()) {
output.push_back(converted.value());
}
}
return output;
}
} // namespace diagnostics_service_converters
} // namespace chromeos
// Copyright 2020 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.
#ifndef CHROMEOS_COMPONENTS_TELEMETRY_EXTENSION_UI_DIAGNOSTICS_SERVICE_CONVERTERS_H_
#define CHROMEOS_COMPONENTS_TELEMETRY_EXTENSION_UI_DIAGNOSTICS_SERVICE_CONVERTERS_H_
#if defined(OFFICIAL_BUILD)
#error Diagnostics service should only be included in unofficial builds.
#endif
#include <vector>
#include "chromeos/components/telemetry_extension_ui/mojom/diagnostics_service.mojom-forward.h"
#include "chromeos/services/cros_healthd/public/mojom/cros_healthd_diagnostics.mojom-forward.h"
namespace chromeos {
namespace diagnostics_service_converters {
// This file contains helper functions used by DiagnosticsService to convert its
// types to/from cros_healthd DiagnosticsService types.
std::vector<health::mojom::DiagnosticRoutineEnum> Convert(
const std::vector<cros_healthd::mojom::DiagnosticRoutineEnum>& input);
} // namespace diagnostics_service_converters
} // namespace chromeos
#endif // CHROMEOS_COMPONENTS_TELEMETRY_EXTENSION_UI_DIAGNOSTICS_SERVICE_CONVERTERS_H_
......@@ -5,5 +5,8 @@
import("//mojo/public/tools/bindings/mojom.gni")
mojom("mojom") {
sources = [ "probe_service.mojom" ]
sources = [
"diagnostics_service.mojom",
"probe_service.mojom",
]
}
// Copyright 2020 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.
//
// cros_healthd daemon implements DiagnosticsService interface, but since
// callers are third-party Telemetry Extensions, we have PII filtering
// in the middle that lives in Chrome.
//
// Currently we expose this interface to WebUI only in Chrome OS and on
// non-official builds so that we can prototype Telemetry Extension, while we
// decide how to expose API to third parties.
//
// This Mojo interface will go through security review before shipping.
//
// This is a subset of the cros_healthd diagnostics service interface which is
// located in src/platform2/diagnostics/mojo/cros_healthd_diagnostics.mojom.
module chromeos.health.mojom;
// Interface for exposing diagnostics service.
interface DiagnosticsService {
// Returns an array of all diagnostic routines that the platform supports.
GetAvailableRoutines()
=> (array<DiagnosticRoutineEnum> available_routines);
};
// Enumeration of each of the diagnostics routines the platform may support.
[Extensible]
enum DiagnosticRoutineEnum {
kBatteryCapacity = 0,
kBatteryHealth = 1,
kUrandom = 2,
kSmartctlCheck = 3,
kAcPower = 4,
kCpuCache = 5,
kCpuStress = 6,
kFloatingPointAccuracy = 7,
kNvmeWearLevel = 8,
kNvmeSelfTest = 9,
kDiskRead = 10,
kPrimeSearch = 11,
kBatteryDischarge = 12,
};
......@@ -10,5 +10,6 @@
<!-- Below mojo script required to run browser tests -->
<script src="chrome://resources/mojo/mojo/public/js/mojo_bindings_lite.js"></script>
<script src="diagnostics_service.mojom-lite.js"></script>
<script src="probe_service.mojom-lite.js"></script>
<script src="trusted_scripts.js"></script>
......@@ -13,9 +13,26 @@
* @enum {string}
*/
const Message = {
DIAGNOSTICS_AVAILABLE_ROUTINES: 'DiagnosticsService.GetAvailableRoutines',
PROBE_TELEMETRY_INFO: 'ProbeService.ProbeTelemetryInfo',
};
/**
* Request message sent by the unprivileged context to request the privileged
* context to diagnostics to get available routines.
* @typedef {null}
*/
let DiagnosticsGetAvailableRoutinesRequest;
/**
* Response message sent by the privileged context containing diagnostic
* routine enums.
* @typedef {{availableRoutines:
* !Array<!chromeos.health.mojom.DiagnosticRoutineEnum>}}
*/
let DiagnosticsGetAvailableRoutinesResponse;
/**
* Request message sent by the unprivileged context to request the privileged
* context to probe telemetry information
......
......@@ -19,6 +19,7 @@
<include name="IDR_TELEMETRY_EXTENSION_MANIFEST" file="manifest.json" type="BINDATA" compress="gzip" />
<include name="IDR_TELEMETRY_EXTENSION_ICON_96" file="app_icon_96.png" type="BINDATA" compress="gzip" />
<include name="IDR_TELEMETRY_EXTENSION_TRUSTED_SCRIPTS_JS" file="trusted_scripts.js" flattenhtml="true" type="BINDATA" compress="gzip" />
<include name="IDR_TELEMETRY_EXTENSION_DIAGNOSTICS_SERVICE_MOJO_LITE_JS" file="${root_gen_dir}/chromeos/components/telemetry_extension_ui/mojom/diagnostics_service.mojom-lite.js" compress="gzip" use_base_dir="false" type="BINDATA" />
<include name="IDR_TELEMETRY_EXTENSION_PROBE_SERVICE_MOJO_LITE_JS" file="${root_gen_dir}/chromeos/components/telemetry_extension_ui/mojom/probe_service.mojom-lite.js" compress="gzip" use_base_dir="false" type="BINDATA" />
<!-- Untrusted app contents. -->
......
......@@ -2,6 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/**
* Pointer to remote implementation of diagnostics service.
* @type {!chromeos.health.mojom.DiagnosticsServiceRemote}
*/
const diagnosticsService = chromeos.health.mojom.DiagnosticsService.getRemote();
/**
* Pointer to remote implementation of probe service.
* @type {!chromeos.health.mojom.ProbeServiceRemote}
......@@ -9,10 +15,15 @@
const probeService = chromeos.health.mojom.ProbeService.getRemote();
const untrustedMessagePipe =
new MessagePipe('chrome-untrusted://telemetry-extension');
new MessagePipe('chrome-untrusted://telemetry-extension');
untrustedMessagePipe.registerHandler(Message.DIAGNOSTICS_AVAILABLE_ROUTINES,
async () => {
return await diagnosticsService.getAvailableRoutines();
});
untrustedMessagePipe.registerHandler(Message.PROBE_TELEMETRY_INFO, async () => {
const response = await probeService.probeTelemetryInfo(
[chromeos.health.mojom.ProbeCategoryEnum.kBattery]);
return {telemetryInfo: response.telemetryInfo};
[chromeos.health.mojom.ProbeCategoryEnum.kBattery]);
return { telemetryInfo: response.telemetryInfo };
});
......@@ -6,4 +6,6 @@
<meta charset="utf-8">
<title>Untrusted Telemetry Extension</title>
<h1 id='untrusted-title'>Telemetry Extension</h1>
<script src="mojo_bindings_lite.js"></script>
<script src="diagnostics_service.mojom-lite.js"></script>
<script src="untrusted_scripts.js"></script>
......@@ -15,3 +15,14 @@ async function requestTelemetryInfo() {
await parentMessagePipe.sendMessage(Message.PROBE_TELEMETRY_INFO));
return response;
}
/**
* Requests a list of available routines.
* @return {!Promise<DiagnosticsGetAvailableRoutinesResponse>}
*/
async function getAvailableRoutines() {
const response = /** @type {!DiagnosticsGetAvailableRoutinesResponse} */ (
await parentMessagePipe.sendMessage(
Message.DIAGNOSTICS_AVAILABLE_ROUTINES));
return response;
}
......@@ -7,6 +7,8 @@
#include <utility>
#include "base/memory/ptr_util.h"
#include "chromeos/components/telemetry_extension_ui/diagnostics_service.h"
#include "chromeos/components/telemetry_extension_ui/mojom/diagnostics_service.mojom.h"
#include "chromeos/components/telemetry_extension_ui/mojom/probe_service.mojom.h"
#include "chromeos/components/telemetry_extension_ui/probe_service.h"
#include "chromeos/components/telemetry_extension_ui/telemetry_extension_untrusted_source.h"
......@@ -15,6 +17,7 @@
#include "content/public/browser/web_ui.h"
#include "content/public/browser/web_ui_data_source.h"
#include "content/public/common/url_constants.h"
#include "mojo/public/js/grit/mojo_bindings_resources.h"
#include "services/network/public/mojom/content_security_policy.mojom.h"
namespace chromeos {
......@@ -34,6 +37,9 @@ CreateTrustedTelemetryExtensionDataSource() {
IDR_TELEMETRY_EXTENSION_ICON_96);
trusted_source->AddResourcePath("trusted_scripts.js",
IDR_TELEMETRY_EXTENSION_TRUSTED_SCRIPTS_JS);
trusted_source->AddResourcePath(
"diagnostics_service.mojom-lite.js",
IDR_TELEMETRY_EXTENSION_DIAGNOSTICS_SERVICE_MOJO_LITE_JS);
trusted_source->AddResourcePath(
"probe_service.mojom-lite.js",
IDR_TELEMETRY_EXTENSION_PROBE_SERVICE_MOJO_LITE_JS);
......@@ -66,6 +72,11 @@ CreateUntrustedTelemetryExtensionDataSource() {
"untrusted_scripts.js", IDR_TELEMETRY_EXTENSION_UNTRUSTED_SCRIPTS_JS);
untrusted_source->AddResourcePath(
"untrusted_worker.js", IDR_TELEMETRY_EXTENSION_UNTRUSTED_WORKER_JS);
untrusted_source->AddResourcePath("mojo_bindings_lite.js",
IDR_MOJO_MOJO_BINDINGS_LITE_JS);
untrusted_source->AddResourcePath(
"diagnostics_service.mojom-lite.js",
IDR_TELEMETRY_EXTENSION_DIAGNOSTICS_SERVICE_MOJO_LITE_JS);
untrusted_source->OverrideContentSecurityPolicy(
network::mojom::CSPDirectiveName::FrameAncestors,
......@@ -99,6 +110,12 @@ void TelemetryExtensionUI::BindInterface(
probe_service_ = std::make_unique<ProbeService>(std::move(receiver));
}
void TelemetryExtensionUI::BindInterface(
mojo::PendingReceiver<health::mojom::DiagnosticsService> receiver) {
diagnostics_service_ =
std::make_unique<DiagnosticsService>(std::move(receiver));
}
WEB_UI_CONTROLLER_TYPE_IMPL(TelemetryExtensionUI)
} // namespace chromeos
......@@ -11,6 +11,7 @@
#include "memory"
#include "chromeos/components/telemetry_extension_ui/mojom/diagnostics_service.mojom-forward.h"
#include "chromeos/components/telemetry_extension_ui/mojom/probe_service.mojom-forward.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "ui/webui/mojo_web_ui_controller.h"
......@@ -25,11 +26,15 @@ class TelemetryExtensionUI : public ui::MojoWebUIController {
TelemetryExtensionUI& operator=(const TelemetryExtensionUI&) = delete;
~TelemetryExtensionUI() override;
void BindInterface(
mojo::PendingReceiver<health::mojom::DiagnosticsService> receiver);
void BindInterface(
mojo::PendingReceiver<health::mojom::ProbeService> receiver);
private:
// Replaced when |BindInterface| is called.
std::unique_ptr<health::mojom::DiagnosticsService> diagnostics_service_;
std::unique_ptr<health::mojom::ProbeService> probe_service_;
WEB_UI_CONTROLLER_TYPE_DECL();
......
......@@ -33,6 +33,7 @@ source_set("browser_test_support") {
"../:telemetry_extension_ui",
"//chrome/test:test_support_ui",
"//chromeos/components/web_applications/test:test_support",
"//chromeos/dbus/cros_healthd:cros_healthd",
]
data = [
......
......@@ -7,6 +7,8 @@
#include "base/files/file_path.h"
#include "chromeos/components/telemetry_extension_ui/url_constants.h"
#include "chromeos/components/web_applications/test/sandboxed_web_ui_test_base.h"
#include "chromeos/dbus/cros_healthd/cros_healthd_client.h"
#include "chromeos/dbus/cros_healthd/fake_cros_healthd_client.h"
namespace {
......@@ -38,3 +40,30 @@ TelemetryExtensionUiBrowserTest::TelemetryExtensionUiBrowserTest()
base::FilePath(kUntrustedTestCases)}) {}
TelemetryExtensionUiBrowserTest::~TelemetryExtensionUiBrowserTest() = default;
void TelemetryExtensionUiBrowserTest::SetUpOnMainThread() {
{
namespace cros_diagnostics = ::chromeos::cros_healthd::mojom;
std::vector<cros_diagnostics::DiagnosticRoutineEnum> input{
cros_diagnostics::DiagnosticRoutineEnum::kBatteryCapacity,
cros_diagnostics::DiagnosticRoutineEnum::kBatteryHealth,
cros_diagnostics::DiagnosticRoutineEnum::kUrandom,
cros_diagnostics::DiagnosticRoutineEnum::kSmartctlCheck,
cros_diagnostics::DiagnosticRoutineEnum::kAcPower,
cros_diagnostics::DiagnosticRoutineEnum::kCpuCache,
cros_diagnostics::DiagnosticRoutineEnum::kCpuStress,
cros_diagnostics::DiagnosticRoutineEnum::kFloatingPointAccuracy,
cros_diagnostics::DiagnosticRoutineEnum::kNvmeWearLevel,
cros_diagnostics::DiagnosticRoutineEnum::kNvmeSelfTest,
cros_diagnostics::DiagnosticRoutineEnum::kDiskRead,
cros_diagnostics::DiagnosticRoutineEnum::kPrimeSearch,
cros_diagnostics::DiagnosticRoutineEnum::kBatteryDischarge,
};
chromeos::cros_healthd::FakeCrosHealthdClient::Get()
->SetAvailableRoutinesForTesting(input);
}
SandboxedWebUiAppTestBase::SetUpOnMainThread();
}
......@@ -18,6 +18,8 @@ class TelemetryExtensionUiBrowserTest : public SandboxedWebUiAppTestBase {
delete;
TelemetryExtensionUiBrowserTest& operator=(
const TelemetryExtensionUiBrowserTest&) = delete;
void SetUpOnMainThread() override;
};
#endif // CHROMEOS_COMPONENTS_TELEMETRY_EXTENSION_UI_TEST_TELEMETRY_EXTENSION_UI_BROWSERTEST_H_
......@@ -81,3 +81,10 @@ TEST_F(
await runTestInUntrusted('UntrustedRequestTelemetryInfo');
testDone();
});
TEST_F(
'TelemetryExtensionUIBrowserTest', 'UntrustedRequestAvailableRoutines',
async () => {
await runTestInUntrusted('UntrustedRequestAvailableRoutines');
testDone();
});
......@@ -71,3 +71,27 @@ UNTRUSTED_TEST('UntrustedRequestTelemetryInfo', async () => {
}
});
});
// Tests that array of available routines can be successfully
// requested from chrome-untrusted://.
UNTRUSTED_TEST('UntrustedRequestAvailableRoutines', async () => {
/** @type {!DiagnosticsGetAvailableRoutinesResponse} */
const response = await getAvailableRoutines();
assertDeepEquals(response, {
'availableRoutines': [
chromeos.health.mojom.DiagnosticRoutineEnum.kBatteryCapacity,
chromeos.health.mojom.DiagnosticRoutineEnum.kBatteryHealth,
chromeos.health.mojom.DiagnosticRoutineEnum.kUrandom,
chromeos.health.mojom.DiagnosticRoutineEnum.kSmartctlCheck,
chromeos.health.mojom.DiagnosticRoutineEnum.kAcPower,
chromeos.health.mojom.DiagnosticRoutineEnum.kCpuCache,
chromeos.health.mojom.DiagnosticRoutineEnum.kCpuStress,
chromeos.health.mojom.DiagnosticRoutineEnum.kFloatingPointAccuracy,
chromeos.health.mojom.DiagnosticRoutineEnum.kNvmeWearLevel,
chromeos.health.mojom.DiagnosticRoutineEnum.kNvmeSelfTest,
chromeos.health.mojom.DiagnosticRoutineEnum.kDiskRead,
chromeos.health.mojom.DiagnosticRoutineEnum.kPrimeSearch,
chromeos.health.mojom.DiagnosticRoutineEnum.kBatteryDischarge,
]
});
});
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