• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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 
16 #include "gtest/gtest.h"
17 #include "drawing_text_global.h"
18 #include "global_config/text_global_config.h"
19 #include "text/text_blob.h"
20 
21 using namespace testing;
22 using namespace testing::ext;
23 using namespace OHOS::Rosen::Drawing;
24 namespace OHOS::Rosen::SrvText {
25 class NdkTextGlobalTest : public testing::Test {};
26 
GetTextHighContrast()27 static uint32_t GetTextHighContrast()
28 {
29     auto& instance = ProcessTextConstrast::Instance();
30     return static_cast<uint32_t>(instance.GetTextContrast());
31 }
32 
33 /*
34 * @tc.name: NdkTextHighContrastTest01
35 * @tc.desc: test for text high contrast mode
36 * @tc.type: FUNC
37 */
38 HWTEST_F(NdkTextGlobalTest, NdkTextHighContrastTest01, TestSize.Level0)
39 {
40     OH_Drawing_SetTextHighContrast(OH_Drawing_TextHighContrast::TEXT_FOLLOW_SYSTEM_HIGH_CONTRAST);
41     EXPECT_EQ(GetTextHighContrast(), OH_Drawing_TextHighContrast::TEXT_FOLLOW_SYSTEM_HIGH_CONTRAST);
42 
43     OH_Drawing_SetTextHighContrast(OH_Drawing_TextHighContrast::TEXT_APP_DISABLE_HIGH_CONTRAST);
44     EXPECT_EQ(GetTextHighContrast(), OH_Drawing_TextHighContrast::TEXT_APP_DISABLE_HIGH_CONTRAST);
45 
46     OH_Drawing_SetTextHighContrast(OH_Drawing_TextHighContrast::TEXT_APP_ENABLE_HIGH_CONTRAST);
47     EXPECT_EQ(GetTextHighContrast(), OH_Drawing_TextHighContrast::TEXT_APP_ENABLE_HIGH_CONTRAST);
48 }
49 
50 /*
51 * @tc.name: NdkTextHighContrastTest02
52 * @tc.desc: test for text high contrast mode(Invalid)
53 * @tc.type: FUNC
54 */
55 HWTEST_F(NdkTextGlobalTest, NdkTextHighContrastTest02, TestSize.Level0)
56 {
57     uint32_t preValue = GetTextHighContrast();
58     OH_Drawing_SetTextHighContrast(static_cast<OH_Drawing_TextHighContrast>(TEXT_HIGH_CONTRAST_BUTT));
59     EXPECT_EQ(GetTextHighContrast(), preValue);
60 }
61 
62 } // namespace OHOS::Rosen::SrvText