Commit 2fe5ffdc authored by Zentaro Kavanagh's avatar Zentaro Kavanagh Committed by Commit Bot

Diagnostics: Add stubs for mojo interface provider

Bug: 1125150
Test: browser_tests --gtest_filter=DiagnosticsApp*
Change-Id: If4c41f6ececc2b635da5b9f63c698cad558cb501
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2411654
Commit-Queue: Zentaro Kavanagh <zentaro@chromium.org>
Reviewed-by: default avatarBailey Berro <baileyberro@chromium.org>
Cr-Commit-Position: refs/heads/master@{#808161}
parent b3960217
......@@ -6,6 +6,9 @@
import 'chrome://resources/mojo/mojo/public/js/mojo_bindings_lite.js';
import 'chrome://diagnostics/diagnostics_app.js';
import {SystemDataProviderInterface} from 'chrome://diagnostics/diagnostics_types.js';
import {getSystemDataProvider, setSystemDataProviderForTesting} from 'chrome://diagnostics/mojo_interface_provider.js';
suite('DiagnosticsAppTest', () => {
/** @type {?DiagnosticsApp} */
let page = null;
......@@ -26,4 +29,14 @@ suite('DiagnosticsAppTest', () => {
// capabilities to test.
assertEquals('Diagnostics', page.$$('#header').textContent);
});
});
\ No newline at end of file
});
suite('FakeMojoProviderTest', () => {
test('SettingGettingTestProvider', () => {
// TODO(zentaro): Replace with fake when built.
let fake_provider =
/** @type {SystemDataProviderInterface} */ (new Object());
setSystemDataProviderForTesting(fake_provider);
assertEquals(fake_provider, getSystemDataProvider());
});
});
......@@ -12,6 +12,8 @@ js_type_check("closure_compile_module") {
deps = [
":diagnostics_app",
":diagnostics_card",
":diagnostics_types",
":mojo_interface_provider",
]
}
......@@ -28,6 +30,13 @@ js_library("diagnostics_card") {
]
}
js_library("diagnostics_types") {
}
js_library("mojo_interface_provider") {
deps = [ "//ui/webui/resources/js:cr.m" ]
}
html_to_js("web_components") {
js_files = [
"diagnostics_app.js",
......
......@@ -16,7 +16,9 @@
<include name="IDR_DIAGNOSTICS_APP_ICON" file="app_icon_192.png" type="BINDATA" />
<include name="IDR_DIAGNOSTICS_APP_INDEX_HTML" file="index.html" type="BINDATA" />
<include name="IDR_DIAGNOSTICS_APP_JS" file="${root_gen_dir}/chromeos/components/diagnostics_ui/resources/diagnostics_app.js" use_base_dir="false" type="BINDATA"/>
<include name="IDR_DIAGNOSTICS_MOJO_INTERFACE_PROVIDER_JS" file="mojo_interface_provider.js" type="BINDATA"/>
<include name="IDR_DIAGNOSTICS_SHARED_CSS_JS" file="${root_gen_dir}/chromeos/components/diagnostics_ui/resources/diagnostics_shared_css.js" use_base_dir="false" type="BINDDATA"/>
<include name="IDR_DIAGNOSTICS_TYPES_JS" file="diagnostics_types.js" type="BINDATA"/>
</includes>
</release>
</grit>
// 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.
/**
* @fileoverview
* Type aliases for the mojo API.
*
* TODO(zentaro): When the fake API is replaced by mojo these can be
* re-aliased to the corresponding mojo types, or replaced by them.
*/
/**
* Type alias for the SystemDataProviderInterface.
* TODO(zentaro): Replace with a real mojo type when implemented.
* @typedef {!Object}
*/
export let SystemDataProviderInterface;
// 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.
import {assert} from 'chrome://resources/js/assert.m.js';
import {SystemDataProviderInterface} from './diagnostics_types.js'
/**
* @fileoverview
* Provides singleton access to mojo interfaces with the ability
* to override them with test/fake implementations.
*/
/**
* @type {?SystemDataProviderInterface}
*/
let systemDataProvider = null;
/**
* @param {!SystemDataProviderInterface} testProvider
*/
export function setSystemDataProviderForTesting(testProvider) {
systemDataProvider = testProvider;
}
/**
* @return {!SystemDataProviderInterface}
*/
export function getSystemDataProvider() {
// TODO(zentaro): Instantiate a real mojo interface here.
assert(!!systemDataProvider);
return systemDataProvider;
}
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