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