blob: 6baad115313eaf805d839cf94481e97dd951d43f [file] [log] [blame]
Tom Sepeza310e002015-02-27 13:03:07 -08001// 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
Tom Sepez1ed8a212015-05-11 15:25:39 -07005#include "../../public/fpdf_formfill.h"
Tom Sepeza310e002015-02-27 13:03:07 -08006#include "../../testing/embedder_test.h"
7#include "../../testing/embedder_test_mock_delegate.h"
Tom Sepez6efc0ad2015-06-02 17:11:18 -07008#include "../../testing/embedder_test_timer_handling_delegate.h"
Tom Sepeza310e002015-02-27 13:03:07 -08009#include "testing/gmock/include/gmock/gmock.h"
10#include "testing/gtest/include/gtest/gtest.h"
11
12using testing::_;
13using testing::Return;
14
Nico Weber9d8ec5a2015-08-04 13:00:21 -070015class FPDFFormFillEmbeddertest : public EmbedderTest {};
Tom Sepeza310e002015-02-27 13:03:07 -080016
17TEST_F(FPDFFormFillEmbeddertest, FirstTest) {
18 EmbedderTestMockDelegate mock;
19 EXPECT_CALL(mock, Alert(_, _, _, _)).Times(0);
20 EXPECT_CALL(mock, UnsupportedHandler(_)).Times(0);
Tom Sepez6efc0ad2015-06-02 17:11:18 -070021 EXPECT_CALL(mock, SetTimer(_, _)).Times(0);
22 EXPECT_CALL(mock, KillTimer(_)).Times(0);
Tom Sepeza310e002015-02-27 13:03:07 -080023 SetDelegate(&mock);
24
25 EXPECT_TRUE(OpenDocument("testing/resources/hello_world.pdf"));
26 FPDF_PAGE page = LoadPage(0);
27 EXPECT_NE(nullptr, page);
Lei Zhangd27acae2015-05-15 15:36:02 -070028 UnloadPage(page);
Tom Sepeza310e002015-02-27 13:03:07 -080029}
Tom Sepez6efc0ad2015-06-02 17:11:18 -070030
31TEST_F(FPDFFormFillEmbeddertest, BUG_487928) {
32 EmbedderTestTimerHandlingDelegate delegate;
33 SetDelegate(&delegate);
34
35 EXPECT_TRUE(OpenDocument("testing/resources/bug_487928.pdf"));
36 FPDF_PAGE page = LoadPage(0);
37 EXPECT_NE(nullptr, page);
38 DoOpenActions();
39 delegate.AdvanceTime(5000);
40 UnloadPage(page);
41}
Tom Sepez0b133982015-07-28 11:23:22 -070042
43TEST_F(FPDFFormFillEmbeddertest, BUG_514690) {
44 EXPECT_TRUE(OpenDocument("testing/resources/hello_world.pdf"));
45 FPDF_PAGE page = LoadPage(0);
46 EXPECT_NE(nullptr, page);
47
48 // Test that FORM_OnMouseMove() etc. permit null HANDLES and PAGES.
49 FORM_OnMouseMove(nullptr, page, 0, 10.0, 10.0);
50 FORM_OnMouseMove(form_handle(), nullptr, 0, 10.0, 10.0);
51
52 UnloadPage(page);
53}