1 /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2 /*
3  *     Copyright 2018 Couchbase, Inc.
4  *
5  *   Licensed under the Apache License, Version 2.0 (the "License");
6  *   you may not use this file except in compliance with the License.
7  *   You may obtain a copy of the License at
8  *
9  *       http://www.apache.org/licenses/LICENSE-2.0
10  *
11  *   Unless required by applicable law or agreed to in writing, software
12  *   distributed under the License is distributed on an "AS IS" BASIS,
13  *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *   See the License for the specific language governing permissions and
15  *   limitations under the License.
16  */
17 
18 #pragma once
19 
20 #include "item_freq_decayer.h"
21 
22 /*
23  * Mock of the ItemFreqDecayerTask class.
24  */
25 class MockItemFreqDecayerTask : public ItemFreqDecayerTask {
26 public:
MockItemFreqDecayerTask(EventuallyPersistentEngine* e, uint16_t percentage_)27     MockItemFreqDecayerTask(EventuallyPersistentEngine* e, uint16_t percentage_)
28         : ItemFreqDecayerTask(e, percentage_) {
29     }
30 
31     // Provide ability to read the completed flag
isCompleted() const32     bool isCompleted() const {
33         return completed;
34     }
35 
36     void wakeup() override {
37         wakeupCalled = true;
38         ItemFreqDecayerTask::wakeup();
39     }
40 
41     // Set the ChunkDuration to 0ms so that it ensures that assuming there
42     // are more than ProgressTracker:INITIAL_VISIT_COUNT_CHECK documents in
43     // the hash table it will require multiple passes to visit all items.
44     std::chrono::milliseconds getChunkDuration() const override {
45         return std::chrono::milliseconds(0);
46     }
47 
48     bool wakeupCalled{false};
49 };
50