• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_METHOD4(Pull, bool(const int pullCode, const ConfigKey& key, const int64_t eventTimeNs,
42                             vector<std::shared_ptr<LogEvent>>* data));
43     MOCK_METHOD4(Pull, bool(const int pullCode, const vector<int32_t>& uids,
44                             const int64_t eventTimeNs, vector<std::shared_ptr<LogEvent>>* data));
45     MOCK_METHOD2(RegisterPullUidProvider,
46                  void(const ConfigKey& configKey, wp<PullUidProvider> provider));
47     MOCK_METHOD2(UnregisterPullUidProvider,
48                  void(const ConfigKey& configKey, wp<PullUidProvider> provider));
49 };
50 
51 HashableDimensionKey getMockedDimensionKey(int tagId, int key, std::string value);
52 MetricDimensionKey getMockedMetricDimensionKey(int tagId, int key, std::string value);
53 
54 HashableDimensionKey getMockedDimensionKeyLongValue(int tagId, int key, int64_t value);
55 MetricDimensionKey getMockedStateDimensionKey(int tagId, int key, int64_t value);
56 
57 // Utils to build FieldMatcher proto for simple one-depth atoms.
58 void buildSimpleAtomFieldMatcher(const int tagId, const int atomFieldNum, FieldMatcher* matcher);
59 void buildSimpleAtomFieldMatcher(const int tagId, FieldMatcher* matcher);
60 
61 }  // namespace statsd
62 }  // namespace os
63 }  // namespace android
64