blob: e786aa83e69d78503a5824a78d611b292f4158a1 [file] [log] [blame]
[email protected]917e86a2011-06-30 21:42:371// Copyright (c) 2011 The Chromium Authors. All rights reserved.
[email protected]de9bdd12010-11-04 00:36:222// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef PPAPI_TESTS_TEST_UTILS_H_
6#define PPAPI_TESTS_TEST_UTILS_H_
7
8#include <string>
9
10#include "ppapi/c/dev/ppb_testing_dev.h"
[email protected]7358d572011-02-15 18:44:4011#include "ppapi/c/pp_instance.h"
[email protected]de9bdd12010-11-04 00:36:2212#include "ppapi/c/pp_stdint.h"
13#include "ppapi/cpp/completion_callback.h"
14
15const PPB_Testing_Dev* GetTestingInterface();
16std::string ReportError(const char* method, int32_t error);
17
18class TestCompletionCallback {
19 public:
[email protected]7358d572011-02-15 18:44:4020 TestCompletionCallback(PP_Instance instance);
[email protected]917e86a2011-06-30 21:42:3721 TestCompletionCallback(PP_Instance instance, bool force_async);
[email protected]de9bdd12010-11-04 00:36:2222
[email protected]26d912d32011-05-02 17:28:1023 // Waits for the callback to be called and returns the
24 // result. Returns immediately if the callback was previously called
25 // and the result wasn't returned (i.e. each result value received
26 // by the callback is returned by WaitForResult() once and only
27 // once).
[email protected]de9bdd12010-11-04 00:36:2228 int32_t WaitForResult();
29
30 operator pp::CompletionCallback() const;
31
[email protected]64264ef2010-12-21 00:45:4332 unsigned run_count() const { return run_count_; }
33 void reset_run_count() { run_count_ = 0; }
34
[email protected]db567f2b2011-04-12 23:28:5935 int32_t result() const { return result_; }
36
[email protected]de9bdd12010-11-04 00:36:2237 private:
38 static void Handler(void* user_data, int32_t result);
39
[email protected]26d912d32011-05-02 17:28:1040 bool have_result_;
[email protected]de9bdd12010-11-04 00:36:2241 int32_t result_;
[email protected]917e86a2011-06-30 21:42:3742 bool force_async_;
[email protected]de9bdd12010-11-04 00:36:2243 bool post_quit_task_;
[email protected]64264ef2010-12-21 00:45:4344 unsigned run_count_;
[email protected]7358d572011-02-15 18:44:4045 PP_Instance instance_;
[email protected]de9bdd12010-11-04 00:36:2246};
47
48#endif // PPAPI_TESTS_TEST_UTILS_H_