1/* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16class MockEnvironmentBackend implements IEnvironmentBackend { 17 private callback_: (key: string, value: any) => void = undefined; 18 getAccessibilityEnabled(): string { 19 return "false"; 20 } 21 getColorMode(): number { 22 return 1; 23 } 24 getFontScale(): number { 25 return 1.0; 26 } 27 getFontWeightScale(): number { 28 return 1.0; 29 } 30 getLayoutDirection(): string { 31 return "LTR"; 32 } 33 getLanguageCode(): string { 34 return "cn"; 35 } 36 37 simulateChange<S>(key: string, value: S): void { 38 if (!this.callback_) 39 return; 40 this.callback_(key, value); 41 } 42 43 onValueChanged(callback: (key: string, value: any) => void): void { 44 this.callback_ = callback; 45 } 46} 47