• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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 "session_stack.h"
18 #include "avsession_log.h"
19 
20 using namespace testing::ext;
21 using namespace OHOS::AVSession;
22 
23 class SessionStackTest : public testing::Test {
24 public:
25     static void SetUpTestCase(void);
26     static void TearDownTestCase(void);
27     void SetUp();
28     void TearDown();
29 };
30 
SetUpTestCase()31 void SessionStackTest::SetUpTestCase()
32 {}
33 
TearDownTestCase()34 void SessionStackTest::TearDownTestCase()
35 {}
36 
SetUp()37 void SessionStackTest::SetUp()
38 {}
39 
TearDown()40 void SessionStackTest::TearDown()
41 {}
42 
43 /**
44 * @tc.name: RemoveSession001
45 * @tc.desc: verifying session stack remove session
46 * @tc.type: FUNC
47 * @tc.require: AR000H31KJ
48 */
49 static HWTEST(SessionStackTest, RemoveSession001, TestSize.Level1)
50 {
51     SLOGI("RemoveSession001 begin!");
52     AVSessionDescriptor descriptor;
53     descriptor.sessionId_ = "123456";
54     descriptor.sessionTag_ = "test";
55     descriptor.sessionType_ = AVSession::SESSION_TYPE_AUDIO;
56     OHOS::AppExecFwk::ElementName elementName;
57     elementName.SetBundleName("test.ohos.avsession");
58     elementName.SetAbilityName("test.ability");
59     descriptor.isThirdPartyApp_ = true;
60     OHOS::sptr<AVSessionItem> expected = new(std::nothrow) AVSessionItem(descriptor);
61     expected->SetPid(1234);
62     expected->SetUid(1234);
63 
64     SessionStack sessionStack;
65     sessionStack.AddSession(1234, elementName.GetAbilityName(), expected);
66     OHOS::sptr<AVSessionItem> actual = sessionStack.RemoveSession("123456");
67 
68     EXPECT_NE(actual, nullptr);
69     SLOGI("RemoveSession001 end!");
70 }