1c38770edbd42c337458fdb2edea533986120aa4
[pdfium.git] / fpdfsdk / src / fpdfformfill_embeddertest.cpp
1 // Copyright 2015 PDFium 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
6 #include "../../public/fpdf_formfill.h"
7 #include "../../testing/embedder_test.h"
8 #include "../../testing/embedder_test_mock_delegate.h"
9 #include "../../testing/embedder_test_timer_handling_delegate.h"
10 #include "testing/gmock/include/gmock/gmock.h"
11 #include "testing/gtest/include/gtest/gtest.h"
12
13 using testing::_;
14 using testing::Return;
15
16 class FPDFFormFillEmbeddertest : public EmbedderTest {
17 };
18
19 TEST_F(FPDFFormFillEmbeddertest, FirstTest) {
20   EmbedderTestMockDelegate mock;
21   EXPECT_CALL(mock, Alert(_, _, _, _)).Times(0);
22   EXPECT_CALL(mock, UnsupportedHandler(_)).Times(0);
23   EXPECT_CALL(mock, SetTimer(_, _)).Times(0);
24   EXPECT_CALL(mock, KillTimer(_)).Times(0);
25   SetDelegate(&mock);
26
27   EXPECT_TRUE(OpenDocument("testing/resources/hello_world.pdf"));
28   FPDF_PAGE page = LoadPage(0);
29   EXPECT_NE(nullptr, page);
30   UnloadPage(page);
31 }
32
33 TEST_F(FPDFFormFillEmbeddertest, BUG_487928) {
34   EmbedderTestTimerHandlingDelegate delegate;
35   SetDelegate(&delegate);
36
37   EXPECT_TRUE(OpenDocument("testing/resources/bug_487928.pdf"));
38   FPDF_PAGE page = LoadPage(0);
39   EXPECT_NE(nullptr, page);
40   DoOpenActions();
41   delegate.AdvanceTime(5000);
42   UnloadPage(page);
43 }
44
45 TEST_F(FPDFFormFillEmbeddertest, BUG_514690) {
46   EXPECT_TRUE(OpenDocument("testing/resources/hello_world.pdf"));
47   FPDF_PAGE page = LoadPage(0);
48   EXPECT_NE(nullptr, page);
49
50   // Test that FORM_OnMouseMove() etc. permit null HANDLES and PAGES.
51   FORM_OnMouseMove(nullptr, page, 0, 10.0, 10.0);
52   FORM_OnMouseMove(form_handle(), nullptr, 0, 10.0, 10.0);
53
54   UnloadPage(page);
55 }