• 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 #ifndef OHOS_SYSTEM_TEST_STEVENT_H
16 #define OHOS_SYSTEM_TEST_STEVENT_H
17 
18 #include <string>
19 #include <vector>
20 #include <condition_variable>
21 #include <cstdio>
22 #include <iostream>
23 #include <unordered_map>
24 #include "hilog_wrapper.h"
25 namespace OHOS {
26 namespace STtools {
27 class Event {
28 public:
29     Event();
30     ~Event();
31     bool Compare();
32     int WaitingMessage(const std::string &message, int timeout_ms, bool locked);
33     void CompleteMessage(const std::string &message);
34     void Clean();
35     std::string GetData(const std::string &message);
36     void CompleteMessage(const std::string &message, const std::string &data);
37 
38 private:
39     std::mutex mutex_;
40     std::condition_variable cv_;
41     std::string waiting_message_;
42     std::vector<std::string> complete_message_;
43     std::unordered_map<std::string, std::string> message_data_;
44 };
45 }  // namespace STtools
46 }  // namespace OHOS
47 #endif  // OHOS_SYSTEM_TEST_STEVENT_H