Home | History | Annotate | Download | only in metrics
      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_METHOD6(query,
     30                  ConditionState(const int conditionIndex, const ConditionKey& conditionParameters,
     31                                 const vector<Matcher>& dimensionFields,
     32                                 const bool isSubsetDim, const bool isPartialLink,
     33                                 std::unordered_set<HashableDimensionKey>* dimensionKeySet));
     34 };
     35 
     36 class MockStatsPullerManager : public StatsPullerManager {
     37 public:
     38     MOCK_METHOD4(RegisterReceiver, void(int tagId, wp<PullDataReceiver> receiver,
     39                                         int64_t nextPulltimeNs, int64_t intervalNs));
     40     MOCK_METHOD2(UnRegisterReceiver, void(int tagId, wp<PullDataReceiver> receiver));
     41     MOCK_METHOD2(Pull, bool(const int pullCode, vector<std::shared_ptr<LogEvent>>* data));
     42 };
     43 
     44 class MockUidMap : public UidMap {
     45  public:
     46   MOCK_CONST_METHOD1(getHostUidOrSelf, int(int uid));
     47 };
     48 
     49 HashableDimensionKey getMockedDimensionKey(int tagId, int key, std::string value);
     50 MetricDimensionKey getMockedMetricDimensionKey(int tagId, int key, std::string value);
     51 
     52 // Utils to build FieldMatcher proto for simple one-depth atoms.
     53 void buildSimpleAtomFieldMatcher(const int tagId, const int atomFieldNum, FieldMatcher* matcher);
     54 void buildSimpleAtomFieldMatcher(const int tagId, FieldMatcher* matcher);
     55 
     56 }  // namespace statsd
     57 }  // namespace os
     58 }  // namespace android