1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41
   42
   43
   44
   45
   46
   47
   48
   49
   50
   51
   52
   53
   54
   55
   56
   57
   58
   59
   60
   61
   62
   63
   64
   65
   66
   67

content / test / mock_overscroll_refresh_handler_android.cc [blame]

// Copyright 2017 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "content/test/mock_overscroll_refresh_handler_android.h"

#include "content/public/test/test_utils.h"

namespace content {

MockOverscrollRefreshHandlerAndroid::MockOverscrollRefreshHandlerAndroid()
    : ui::OverscrollRefreshHandler(nullptr) {}

MockOverscrollRefreshHandlerAndroid::~MockOverscrollRefreshHandlerAndroid() {}

bool MockOverscrollRefreshHandlerAndroid::PullStart(
    OverscrollAction type,
    std::optional<ui::BackGestureEventSwipeEdge> initiating_edge) {
  // The first GestureScrollUpdate starts the pull, but does not update the
  // pull. For the purpose of testing, we'll be consistent with aura
  // overscroll and consider this an update.
  OnPullUpdate();
  return true;
}

void MockOverscrollRefreshHandlerAndroid::PullUpdate(float, float) {
  OnPullUpdate();
}

void MockOverscrollRefreshHandlerAndroid::PullRelease(bool) {
  OnPullEnd();
}

void MockOverscrollRefreshHandlerAndroid::PullReset() {
  OnPullEnd();
}

void MockOverscrollRefreshHandlerAndroid::WaitForUpdate() {
  if (!seen_update_)
    update_message_loop_runner_->Run();
}

void MockOverscrollRefreshHandlerAndroid::WaitForEnd() {
  if (!pull_ended_)
    end_message_loop_runner_->Run();
}

void MockOverscrollRefreshHandlerAndroid::Reset() {
  update_message_loop_runner_ = new MessageLoopRunner;
  end_message_loop_runner_ = new MessageLoopRunner;
  seen_update_ = false;
  pull_ended_ = false;
}

void MockOverscrollRefreshHandlerAndroid::OnPullUpdate() {
  seen_update_ = true;
  if (update_message_loop_runner_->loop_running())
    update_message_loop_runner_->Quit();
}

void MockOverscrollRefreshHandlerAndroid::OnPullEnd() {
  pull_ended_ = true;
  if (end_message_loop_runner_->loop_running())
    end_message_loop_runner_->Quit();
}

}  // namespace content