1 /* 2 * Copyright (C) 2017 Google Inc. and others 3 * 4 * This program and the accompanying materials are made available under the 5 * terms of the Eclipse Distribution License v. 1.0 which is available at 6 * https://www.eclipse.org/org/documents/edl-v10.php. 7 * 8 * SPDX-License-Identifier: BSD-3-Clause 9 */ 10 11 package org.eclipse.jgit.junit; 12 13 import static org.junit.Assert.assertEquals; 14 15 import org.eclipse.jgit.lib.ProgressMonitor; 16 17 /** 18 * Strict work monitor 19 */ 20 public final class StrictWorkMonitor implements ProgressMonitor { 21 private int lastWork, totalWork; 22 23 /** {@inheritDoc} */ 24 @Override start(int totalTasks)25 public void start(int totalTasks) { 26 // empty 27 } 28 29 /** {@inheritDoc} */ 30 @Override beginTask(String title, int total)31 public void beginTask(String title, int total) { 32 this.totalWork = total; 33 lastWork = 0; 34 } 35 36 /** {@inheritDoc} */ 37 @Override update(int completed)38 public void update(int completed) { 39 lastWork += completed; 40 } 41 42 /** {@inheritDoc} */ 43 @Override endTask()44 public void endTask() { 45 assertEquals("Units of work recorded", totalWork, lastWork); 46 } 47 48 /** {@inheritDoc} */ 49 @Override isCancelled()50 public boolean isCancelled() { 51 return false; 52 } 53 } 54