• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
16 #include <gtest/gtest.h>
17 #include <gtest/gtest.h>
18 
19 #define private public
20 #include "start_options.h"
21 #undef private
22 
23 #include "ability_window_configuration.h"
24 #include "parcel.h"
25 
26 using namespace testing::ext;
27 namespace OHOS {
28 namespace AAFwk {
29 namespace {
30 const int32_t TEST_DISPLAY_ID = 1;
31 } // namespace
32 
33 class StartOptionsTest : public testing::Test {
34 public:
35     static void SetUpTestCase();
36     static void TearDownTestCase();
37     void SetUp();
38     void TearDown();
39 };
40 
SetUpTestCase()41 void StartOptionsTest::SetUpTestCase()
42 {}
43 
TearDownTestCase()44 void StartOptionsTest::TearDownTestCase()
45 {}
46 
SetUp()47 void StartOptionsTest::SetUp()
48 {}
49 
TearDown()50 void StartOptionsTest::TearDown()
51 {}
52 
53 /**
54  * @tc.name: start_options_test_001
55  * @tc.desc: test class StartOptions number function
56  * @tc.type: FUNC
57  */
58 HWTEST_F(StartOptionsTest, start_options_test_001, TestSize.Level1)
59 {
60     StartOptions startOptions;
61     startOptions.SetWindowMode(AbilityWindowConfiguration::MULTI_WINDOW_DISPLAY_FULLSCREEN);
62     startOptions.SetDisplayID(TEST_DISPLAY_ID);
63     EXPECT_EQ(startOptions.GetWindowMode(), AbilityWindowConfiguration::MULTI_WINDOW_DISPLAY_FULLSCREEN);
64     EXPECT_EQ(startOptions.GetDisplayID(), TEST_DISPLAY_ID);
65 
66     StartOptions secondStartOptions(startOptions);
67     EXPECT_EQ(startOptions.GetWindowMode(), AbilityWindowConfiguration::MULTI_WINDOW_DISPLAY_FULLSCREEN);
68     EXPECT_EQ(startOptions.GetDisplayID(), TEST_DISPLAY_ID);
69 
70     StartOptions thirdStartOptions = secondStartOptions;
71     EXPECT_EQ(startOptions.GetWindowMode(), AbilityWindowConfiguration::MULTI_WINDOW_DISPLAY_FULLSCREEN);
72     EXPECT_EQ(startOptions.GetDisplayID(), TEST_DISPLAY_ID);
73 
74     Parcel parcel;
75     int ret1 = startOptions.Marshalling(parcel);
76     EXPECT_EQ(ret1, true);
77     auto retOptions = startOptions.Unmarshalling(parcel);
78     EXPECT_EQ(retOptions->GetWindowMode(), AbilityWindowConfiguration::MULTI_WINDOW_DISPLAY_FULLSCREEN);
79     EXPECT_EQ(retOptions->GetDisplayID(), TEST_DISPLAY_ID);
80 
81     StartOptions fourthStartOptions;
82     EXPECT_TRUE(startOptions.Marshalling(parcel));
83     auto ret2 = fourthStartOptions.ReadFromParcel(parcel);
84     EXPECT_EQ(ret2, true);
85     EXPECT_EQ(fourthStartOptions.GetWindowMode(), AbilityWindowConfiguration::MULTI_WINDOW_DISPLAY_FULLSCREEN);
86     EXPECT_EQ(fourthStartOptions.GetDisplayID(), TEST_DISPLAY_ID);
87 }
88 }  // namespace AppExecFwk
89 }  // namespace OHOS
90