Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(237)

Side by Side Diff: fpdfsdk/fpdfformfill_embeddertest.cpp

Issue 2211513002: Add test for bug 620428 (setinterval cancellation) (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: wordsmith Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | public/fpdf_formfill.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 PDFium Authors. All rights reserved. 1 // Copyright 2015 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "public/fpdf_formfill.h" 5 #include "public/fpdf_formfill.h"
6 #include "testing/embedder_test.h" 6 #include "testing/embedder_test.h"
7 #include "testing/embedder_test_mock_delegate.h" 7 #include "testing/embedder_test_mock_delegate.h"
8 #include "testing/embedder_test_timer_handling_delegate.h" 8 #include "testing/embedder_test_timer_handling_delegate.h"
9 #include "testing/gmock/include/gmock/gmock.h" 9 #include "testing/gmock/include/gmock/gmock.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 59
60 // Test that FORM_OnMouseMove() etc. permit null HANDLES and PAGES. 60 // Test that FORM_OnMouseMove() etc. permit null HANDLES and PAGES.
61 FORM_OnMouseMove(nullptr, page, 0, 10.0, 10.0); 61 FORM_OnMouseMove(nullptr, page, 0, 10.0, 10.0);
62 FORM_OnMouseMove(form_handle(), nullptr, 0, 10.0, 10.0); 62 FORM_OnMouseMove(form_handle(), nullptr, 0, 10.0, 10.0);
63 63
64 UnloadPage(page); 64 UnloadPage(page);
65 } 65 }
66 66
67 #ifdef PDF_ENABLE_V8 67 #ifdef PDF_ENABLE_V8
68 TEST_F(FPDFFormFillEmbeddertest, BUG_551248) { 68 TEST_F(FPDFFormFillEmbeddertest, BUG_551248) {
69 // Test that timers fire once and intervals fire repeatedly.
69 EmbedderTestTimerHandlingDelegate delegate; 70 EmbedderTestTimerHandlingDelegate delegate;
70 SetDelegate(&delegate); 71 SetDelegate(&delegate);
71 72
72 EXPECT_TRUE(OpenDocument("bug_551248.pdf")); 73 EXPECT_TRUE(OpenDocument("bug_551248.pdf"));
73 FPDF_PAGE page = LoadPage(0); 74 FPDF_PAGE page = LoadPage(0);
75 EXPECT_TRUE(page);
76 DoOpenActions();
77
78 const auto& alerts = delegate.GetAlerts();
79 EXPECT_EQ(0U, alerts.size());
80
81 delegate.AdvanceTime(1000);
82 EXPECT_EQ(0U, alerts.size()); // nothing fired.
83 delegate.AdvanceTime(1000);
84 EXPECT_EQ(1U, alerts.size()); // interval fired.
85 delegate.AdvanceTime(1000);
86 EXPECT_EQ(2U, alerts.size()); // timer fired.
87 delegate.AdvanceTime(1000);
88 EXPECT_EQ(3U, alerts.size()); // interval fired again.
89 delegate.AdvanceTime(1000);
90 UnloadPage(page);
91
92 ASSERT_EQ(3U, alerts.size()); // nothing else fired.
93
94 EXPECT_STREQ(L"interval fired", alerts[0].message.c_str());
95 EXPECT_STREQ(L"Alert", alerts[0].title.c_str());
96 EXPECT_EQ(0, alerts[0].type);
97 EXPECT_EQ(0, alerts[0].icon);
98
99 EXPECT_STREQ(L"timer fired", alerts[1].message.c_str());
100 EXPECT_STREQ(L"Alert", alerts[1].title.c_str());
101 EXPECT_EQ(0, alerts[1].type);
102 EXPECT_EQ(0, alerts[1].icon);
103
104 EXPECT_STREQ(L"interval fired", alerts[2].message.c_str());
105 EXPECT_STREQ(L"Alert", alerts[2].title.c_str());
106 EXPECT_EQ(0, alerts[2].type);
107 EXPECT_EQ(0, alerts[2].icon);
108 }
109
110 TEST_F(FPDFFormFillEmbeddertest, BUG_620428) {
111 // Test that timers and intervals are cancelable.
112 EmbedderTestTimerHandlingDelegate delegate;
113 SetDelegate(&delegate);
114
115 EXPECT_TRUE(OpenDocument("bug_620428.pdf"));
116 FPDF_PAGE page = LoadPage(0);
74 EXPECT_NE(nullptr, page); 117 EXPECT_NE(nullptr, page);
Lei Zhang 2016/08/03 20:36:52 Do EXPECT_TRUE() like line 75?
Tom Sepez 2016/08/03 20:43:31 Done throughout.
75 DoOpenActions(); 118 DoOpenActions();
76 delegate.AdvanceTime(5000); 119 delegate.AdvanceTime(1000);
Lei Zhang 2016/08/03 20:36:52 Does this behaves different vs delegate.AdvanceTim
Tom Sepez 2016/08/03 20:43:31 Kinda sorta. The clumsy test harness doesn't sche
120 delegate.AdvanceTime(1000);
121 delegate.AdvanceTime(1000);
122 delegate.AdvanceTime(1000);
123 delegate.AdvanceTime(1000);
77 UnloadPage(page); 124 UnloadPage(page);
78 125
79 const auto& alerts = delegate.GetAlerts(); 126 const auto& alerts = delegate.GetAlerts();
80 ASSERT_EQ(1U, alerts.size()); 127 EXPECT_EQ(0U, alerts.size());
128 }
81 129
82 EXPECT_STREQ(L"hello world", alerts[0].message.c_str());
83 EXPECT_STREQ(L"Alert", alerts[0].title.c_str());
84 EXPECT_EQ(0, alerts[0].type);
85 EXPECT_EQ(0, alerts[0].icon);
86 }
87 #endif // PDF_ENABLE_V8 130 #endif // PDF_ENABLE_V8
OLDNEW
« no previous file with comments | « no previous file | public/fpdf_formfill.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698