0" class="enable-config-opt">
+
0"
+ class="enable-config-opt">
{{ enableConfig.name }}
0"
+ *ngIf="tracingConfig.getTraceConfig()[traceKey].config?.selectionConfigs.length > 0"
class="selection-config-opt">
{{ selectionConfig.name }}
@@ -67,7 +80,7 @@ import {TracingConfig} from 'trace_collection/tracing_config';
+ [disabled]="!tracingConfig.getTraceConfig()[traceKey].run">
{{
option
}}
@@ -95,12 +108,12 @@ import {TracingConfig} from 'trace_collection/tracing_config';
})
export class TraceConfigComponent {
objectKeys = Object.keys;
- traces = TracingConfig.getInstance().getTracingConfig();
+ tracingConfig = TracingConfig.getInstance();
advancedConfigTraces() {
const advancedConfigs: string[] = [];
- Object.keys(this.traces).forEach((traceKey: string) => {
- if (this.traces[traceKey].config) {
+ Object.keys(this.tracingConfig.getTraceConfig()).forEach((traceKey: string) => {
+ if (this.tracingConfig.getTraceConfig()[traceKey].config) {
advancedConfigs.push(traceKey);
}
});
diff --git a/tools/winscope/src/app/components/trace_config_component_test.ts b/tools/winscope/src/app/components/trace_config_component_test.ts
index 752cededf..2c8775e02 100644
--- a/tools/winscope/src/app/components/trace_config_component_test.ts
+++ b/tools/winscope/src/app/components/trace_config_component_test.ts
@@ -46,7 +46,7 @@ describe('TraceConfigComponent', () => {
fixture = TestBed.createComponent(TraceConfigComponent);
component = fixture.componentInstance;
htmlElement = fixture.nativeElement;
- component.traces = {
+ component.tracingConfig.setTraceConfig({
layers_trace: {
name: 'layers_trace',
isTraceCollection: undefined,
@@ -69,7 +69,8 @@ describe('TraceConfigComponent', () => {
],
},
},
- };
+ });
+ fixture.detectChanges();
});
it('can be created', () => {
@@ -77,7 +78,7 @@ describe('TraceConfigComponent', () => {
});
it('check that trace checkbox ticked on default run', () => {
- component.traces['layers_trace'].run = true;
+ component.tracingConfig.getTraceConfig()['layers_trace'].run = true;
fixture.detectChanges();
const box = htmlElement.querySelector('.trace-checkbox');
expect(box?.innerHTML).toContain('aria-checked="true"');
@@ -85,32 +86,18 @@ describe('TraceConfigComponent', () => {
});
it('check that trace checkbox not ticked on default run', () => {
- component.traces['layers_trace'].run = false;
+ component.tracingConfig.getTraceConfig()['layers_trace'].run = false;
fixture.detectChanges();
const box = htmlElement.querySelector('.trace-checkbox');
expect(box?.innerHTML).toContain('aria-checked="false"');
});
- it('check that correct advanced enable config shows', () => {
- component.traces['layers_trace'].config!.selectionConfigs = [];
- fixture.detectChanges();
-
+ it('check that advanced configs show', () => {
const enable_config_opt = htmlElement.querySelector('.enable-config-opt');
expect(enable_config_opt).toBeTruthy();
expect(enable_config_opt?.innerHTML).toContain('trace buffers');
expect(enable_config_opt?.innerHTML).not.toContain('tracing level');
- const selection_config_opt = htmlElement.querySelector('.selection-config-opt');
- expect(selection_config_opt).toBeFalsy();
- });
-
- it('check that correct advanced selection config shows', () => {
- component.traces['layers_trace'].config!.enableConfigs = [];
- fixture.detectChanges();
-
- const enable_config_opt = htmlElement.querySelector('.enable-config-opt');
- expect(enable_config_opt).toBeFalsy();
-
const selection_config_opt = htmlElement.querySelector('.selection-config-opt');
expect(selection_config_opt).toBeTruthy();
expect(selection_config_opt?.innerHTML).not.toContain('trace buffers');
@@ -118,7 +105,8 @@ describe('TraceConfigComponent', () => {
});
it('check that changing enable config causes box to change', async () => {
- component.traces['layers_trace'].config!.enableConfigs[0].enabled = false;
+ component.tracingConfig.getTraceConfig()['layers_trace'].config!.enableConfigs[0].enabled =
+ false;
fixture.detectChanges();
await fixture.whenStable();
expect(htmlElement.querySelector('.enable-config')?.innerHTML).toContain(
@@ -129,7 +117,8 @@ describe('TraceConfigComponent', () => {
it('check that changing selected config causes select to change', async () => {
fixture.detectChanges();
expect(htmlElement.querySelector('.config-selection')?.innerHTML).toContain('value="debug"');
- component.traces['layers_trace'].config!.selectionConfigs[0].value = 'verbose';
+ component.tracingConfig.getTraceConfig()['layers_trace'].config!.selectionConfigs[0].value =
+ 'verbose';
fixture.detectChanges();
await fixture.whenStable();
expect(htmlElement.querySelector('.config-selection')?.innerHTML).toContain('value="verbose"');
diff --git a/tools/winscope/src/trace_collection/proxy_connection.ts b/tools/winscope/src/trace_collection/proxy_connection.ts
index 19bb6fa68..231e0a5b2 100644
--- a/tools/winscope/src/trace_collection/proxy_connection.ts
+++ b/tools/winscope/src/trace_collection/proxy_connection.ts
@@ -182,7 +182,7 @@ export class ProxyConnection implements Connection {
}
if (newState === ProxyState.START_TRACE) {
const isWaylandAvailable = await this.isWaylandAvailable();
- TracingConfig.getInstance().setTracingConfigForAvailableTraces(isWaylandAvailable);
+ TracingConfig.getInstance().setTraceConfigForAvailableTraces(isWaylandAvailable);
}
this.proxyStateChangeCallback(newState);
}
diff --git a/tools/winscope/src/trace_collection/tracing_config.ts b/tools/winscope/src/trace_collection/tracing_config.ts
index 014ed6905..ddee901b6 100644
--- a/tools/winscope/src/trace_collection/tracing_config.ts
+++ b/tools/winscope/src/trace_collection/tracing_config.ts
@@ -13,28 +13,64 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+import {globalConfig} from 'common/global_config';
import {PersistentStoreProxy} from 'common/persistent_store_proxy';
+import {MockStorage} from 'test/unit/mock_storage';
import {TraceConfigurationMap, TRACES} from './trace_collection_utils';
export class TracingConfig {
requestedTraces: string[] = [];
requestedDumps: string[] = [];
- private storage: Storage | undefined;
- private tracingConfig: TraceConfigurationMap | undefined;
- private dumpConfig: TraceConfigurationMap | undefined;
+ private storage: Storage;
+ private traceConfig: TraceConfigurationMap;
+ private dumpConfig: TraceConfigurationMap;
+
+ private static instance: TracingConfig | undefined;
static getInstance(): TracingConfig {
- return setTracesInstance;
+ if (!TracingConfig.instance) {
+ TracingConfig.instance = new TracingConfig();
+ }
+ return TracingConfig.instance;
}
- initialize(storage: Storage) {
- this.storage = storage;
- this.tracingConfig = PersistentStoreProxy.new(
+ setTraceConfigForAvailableTraces(isWaylandAvailable = false) {
+ const availableTracesConfig = TRACES['default'];
+ if (isWaylandAvailable) {
+ Object.assign(availableTracesConfig, TRACES['arc']);
+ }
+ this.setTraceConfig(availableTracesConfig);
+ }
+
+ setTraceConfig(traceConfig: TraceConfigurationMap) {
+ this.traceConfig = PersistentStoreProxy.new(
+ 'TraceConfiguration',
+ traceConfig,
+ this.storage
+ );
+ }
+
+ getTraceConfig(): TraceConfigurationMap {
+ return this.traceConfig;
+ }
+
+ getDumpConfig(): TraceConfigurationMap {
+ if (this.dumpConfig === undefined) {
+ throw Error('Dump config not initialized yet');
+ }
+ return this.dumpConfig;
+ }
+
+ private constructor() {
+ this.storage = globalConfig.MODE === 'PROD' ? localStorage : new MockStorage();
+
+ this.traceConfig = PersistentStoreProxy.new(
'TracingSettings',
TRACES['default'],
this.storage
);
+
this.dumpConfig = PersistentStoreProxy.new(
'DumpSettings',
{
@@ -54,43 +90,4 @@ export class TracingConfig {
this.storage
);
}
-
- setTracingConfigForAvailableTraces(isWaylandAvailable = false) {
- const availableTracesConfig = TRACES['default'];
- if (isWaylandAvailable) {
- Object.assign(availableTracesConfig, TRACES['arc']);
- }
- this.setTracingConfig(availableTracesConfig);
- }
-
- tracingConfigIsSet(): boolean {
- return this.tracingConfig !== undefined;
- }
-
- getTracingConfig(): TraceConfigurationMap {
- if (this.tracingConfig === undefined) {
- throw Error('Tracing config not initialized yet');
- }
- return this.tracingConfig;
- }
-
- private setTracingConfig(traceConfig: TraceConfigurationMap) {
- if (this.storage === undefined) {
- throw Error('not initialized');
- }
- this.tracingConfig = PersistentStoreProxy.new(
- 'TraceConfiguration',
- traceConfig,
- this.storage
- );
- }
-
- getDumpConfig(): TraceConfigurationMap {
- if (this.dumpConfig === undefined) {
- throw Error('Dump config not initialized yet');
- }
- return this.dumpConfig;
- }
}
-
-const setTracesInstance = new TracingConfig();