1 // Copyright (C) 2017 The Android Open Source Project
2 //
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 #pragma once
15 
16 #include "src/condition/ConditionWizard.h"
17 #include "src/external/StatsPullerManager.h"
18 #include "src/packages/UidMap.h"
19 
20 #include <gmock/gmock.h>
21 #include <gtest/gtest.h>
22 
23 namespace android {
24 namespace os {
25 namespace statsd {
26 
27 class MockConditionWizard : public ConditionWizard {
28 public:
29     MOCK_METHOD3(query,
30                  ConditionState(const int conditionIndex, const ConditionKey& conditionParameters,
31                                 const bool isPartialLink));
32 };
33 
34 class MockStatsPullerManager : public StatsPullerManager {
35 public:
36     MOCK_METHOD5(RegisterReceiver,
37                  void(int tagId, const ConfigKey& key, wp<PullDataReceiver> receiver,
38                       int64_t nextPulltimeNs, int64_t intervalNs));
39     MOCK_METHOD3(UnRegisterReceiver,
40                  void(int tagId, const ConfigKey& key, wp<PullDataReceiver> receiver));
41     MOCK_METHOD5(Pull, bool(const int pullCode, const ConfigKey& key, const int64_t eventTimeNs,
42                             vector<std::shared_ptr<LogEvent>>* data, bool useUids));
43     MOCK_METHOD5(Pull,
44                  bool(const int pullCode, const vector<int32_t>& uids, const int64_t eventTimeNs,
45                       vector<std::shared_ptr<LogEvent>>* data, bool useUids));
46     MOCK_METHOD2(RegisterPullUidProvider,
47                  void(const ConfigKey& configKey, wp<PullUidProvider> provider));
48     MOCK_METHOD2(UnregisterPullUidProvider,
49                  void(const ConfigKey& configKey, wp<PullUidProvider> provider));
50 };
51 
52 HashableDimensionKey getMockedDimensionKey(int tagId, int key, std::string value);
53 MetricDimensionKey getMockedMetricDimensionKey(int tagId, int key, std::string value);
54 
55 HashableDimensionKey getMockedDimensionKeyLongValue(int tagId, int key, int64_t value);
56 MetricDimensionKey getMockedStateDimensionKey(int tagId, int key, int64_t value);
57 
58 // Utils to build FieldMatcher proto for simple one-depth atoms.
59 void buildSimpleAtomFieldMatcher(const int tagId, const int atomFieldNum, FieldMatcher* matcher);
60 void buildSimpleAtomFieldMatcher(const int tagId, FieldMatcher* matcher);
61 
62 }  // namespace statsd
63 }  // namespace os
64 }  // namespace android
65