summaryrefslogtreecommitdiffstats
path: root/ppapi/tests/test_utils.h
blob: b71cc054ccdd2ba9c24adece1a72b4fedbe5b2ae (plain)
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
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef PPAPI_TESTS_TEST_UTILS_H_
#define PPAPI_TESTS_TEST_UTILS_H_

#include <string>

#include "ppapi/c/dev/ppb_testing_dev.h"
#include "ppapi/c/pp_instance.h"
#include "ppapi/c/pp_stdint.h"
#include "ppapi/cpp/completion_callback.h"

const PPB_Testing_Dev* GetTestingInterface();
std::string ReportError(const char* method, int32_t error);

class TestCompletionCallback {
 public:
  TestCompletionCallback(PP_Instance instance);

  int32_t WaitForResult();

  operator pp::CompletionCallback() const;

  unsigned run_count() const { return run_count_; }
  void reset_run_count() { run_count_ = 0; }

  int32_t result() const { return result_; }

 private:
  static void Handler(void* user_data, int32_t result);

  int32_t result_;
  bool post_quit_task_;
  unsigned run_count_;
  PP_Instance instance_;
};

#endif  // PPAPI_TESTS_TEST_UTILS_H_