blob: f040bf9f37aea819cf7fa321f1c74af4cb9d668d [file] [log] [blame]
Yao Chen93fe3a32017-11-02 13:52:59 -07001// 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"
Chenjie Yu6736c892017-11-09 10:50:09 -080017#include "src/external/StatsPullerManager.h"
Chenjie Yu80f91122018-01-31 20:24:50 -080018#include "src/packages/UidMap.h"
Yao Chen93fe3a32017-11-02 13:52:59 -070019
20#include <gmock/gmock.h>
21#include <gtest/gtest.h>
22
23namespace android {
24namespace os {
25namespace statsd {
26
27class MockConditionWizard : public ConditionWizard {
28public:
Yangster13fb7e42018-03-07 17:30:49 -080029 MOCK_METHOD6(query,
Yao Chen8a8d16c2018-02-08 14:50:40 -080030 ConditionState(const int conditionIndex, const ConditionKey& conditionParameters,
31 const vector<Matcher>& dimensionFields,
Yangster13fb7e42018-03-07 17:30:49 -080032 const bool isSubsetDim, const bool isPartialLink,
Yao Chen8a8d16c2018-02-08 14:50:40 -080033 std::unordered_set<HashableDimensionKey>* dimensionKeySet));
Yao Chen93fe3a32017-11-02 13:52:59 -070034};
35
Chenjie Yu6736c892017-11-09 10:50:09 -080036class MockStatsPullerManager : public StatsPullerManager {
37public:
38 MOCK_METHOD3(RegisterReceiver, void(int tagId, wp<PullDataReceiver> receiver, long intervalMs));
39 MOCK_METHOD2(UnRegisterReceiver, void(int tagId, wp<PullDataReceiver> receiver));
40 MOCK_METHOD2(Pull, bool(const int pullCode, vector<std::shared_ptr<LogEvent>>* data));
41};
42
Chenjie Yu80f91122018-01-31 20:24:50 -080043class MockUidMap : public UidMap {
44 public:
45 MOCK_CONST_METHOD1(getHostUidOrSelf, int(int uid));
46};
47
Yangster-mac20877162017-12-22 17:19:39 -080048HashableDimensionKey getMockedDimensionKey(int tagId, int key, std::string value);
Yangster-mac93694462018-01-22 20:49:31 -080049MetricDimensionKey getMockedMetricDimensionKey(int tagId, int key, std::string value);
Yao Chend5aa01b32017-12-19 16:46:36 -080050
Yao Chen8a8d16c2018-02-08 14:50:40 -080051// Utils to build FieldMatcher proto for simple one-depth atoms.
52void buildSimpleAtomFieldMatcher(const int tagId, const int atomFieldNum, FieldMatcher* matcher);
53void buildSimpleAtomFieldMatcher(const int tagId, FieldMatcher* matcher);
54
Yao Chen93fe3a32017-11-02 13:52:59 -070055} // namespace statsd
56} // namespace os
Yao Chend5aa01b32017-12-19 16:46:36 -080057} // namespace android