1// Copyright (c) 2011 The Chromium Authors. All rights reserved.
2// 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_TEST_TEST_VIEW_H_
6#define PPAPI_TEST_TEST_VIEW_H_
7
8#include "ppapi/cpp/view.h"
9#include "ppapi/tests/test_case.h"
10
11class TestView : public TestCase {
12 public:
13  TestView(TestingInstance* instance);
14
15  virtual void DidChangeView(const pp::View& view);
16
17  // TestCase implementation.
18  virtual bool Init();
19  virtual void RunTests(const std::string& test_filter);
20
21 private:
22  // Waits until we get a view changed event. Note that the browser may give
23  // us any number of view changed events, so tests that use this should
24  // expect that there may be spurious events and handle them accordingly.
25  // Note also that view changed sequencing can change between different
26  // versions of WebKit.
27  //
28  // Returns true if we got a view changed, false if it timed out.
29  bool WaitUntilViewChanged();
30
31  void QuitMessageLoop(int32_t result);
32
33  std::string TestCreatedVisible();
34  std::string TestCreatedInvisible();
35  std::string TestPageHideShow();
36  std::string TestSizeChange();
37  std::string TestClipChange();
38  std::string TestScrollOffsetChange();
39
40  pp::View last_view_;
41
42  // DidChangeView stores the page visibility in this vector on each
43  // invocation so tests can check it.
44  std::vector<bool> page_visibility_log_;
45
46  // Set to true to request that the next invocation of DidChangeView should
47  // post a quit to the message loop. DidChangeView will also reset the flag so
48  // this will only happen once.
49  bool post_quit_on_view_changed_;
50};
51
52#endif  // PPAPI_TEST_TEST_VIEW_H_
53