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

Side by Side Diff: fpdfsdk/fpdfformfill_embeddertest.cpp

Issue 2247083002: Merge to M53: Fix issue when firing TimerProc() destroys timer (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@2785
Patch Set: 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 | fpdfsdk/javascript/JS_Object.cpp » ('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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 UnloadPage(page); 77 UnloadPage(page);
78 78
79 const auto& alerts = delegate.GetAlerts(); 79 const auto& alerts = delegate.GetAlerts();
80 ASSERT_EQ(1U, alerts.size()); 80 ASSERT_EQ(1U, alerts.size());
81 81
82 EXPECT_STREQ(L"hello world", alerts[0].message.c_str()); 82 EXPECT_STREQ(L"hello world", alerts[0].message.c_str());
83 EXPECT_STREQ(L"Alert", alerts[0].title.c_str()); 83 EXPECT_STREQ(L"Alert", alerts[0].title.c_str());
84 EXPECT_EQ(0, alerts[0].type); 84 EXPECT_EQ(0, alerts[0].type);
85 EXPECT_EQ(0, alerts[0].icon); 85 EXPECT_EQ(0, alerts[0].icon);
86 } 86 }
87
88 TEST_F(FPDFFormFillEmbeddertest, BUG_620428) {
89 // Test that timers and intervals are cancelable.
90 EmbedderTestTimerHandlingDelegate delegate;
91 SetDelegate(&delegate);
92
93 EXPECT_TRUE(OpenDocument("bug_620428.pdf"));
94 FPDF_PAGE page = LoadPage(0);
95 EXPECT_TRUE(page);
96 DoOpenActions();
97 delegate.AdvanceTime(5000);
98 UnloadPage(page);
99
100 const auto& alerts = delegate.GetAlerts();
101 ASSERT_EQ(1U, alerts.size());
102 EXPECT_STREQ(L"done", alerts[0].message.c_str());
103 }
104
105 TEST_F(FPDFFormFillEmbeddertest, BUG_634394) {
106 // Cancel timer inside timer callback.
107 EmbedderTestTimerHandlingDelegate delegate;
108 SetDelegate(&delegate);
109
110 EXPECT_TRUE(OpenDocument("bug_634394.pdf"));
111 FPDF_PAGE page = LoadPage(0);
112 EXPECT_TRUE(page);
113 DoOpenActions();
114
115 // Timers fire at most once per AdvanceTime(), allow intervals
116 // to fire several times if possible.
117 delegate.AdvanceTime(1000);
118 delegate.AdvanceTime(1000);
119 delegate.AdvanceTime(1000);
120 delegate.AdvanceTime(1000);
121 delegate.AdvanceTime(1000);
122 UnloadPage(page);
123
124 const auto& alerts = delegate.GetAlerts();
125 EXPECT_EQ(2U, alerts.size());
126 }
127
87 #endif // PDF_ENABLE_V8 128 #endif // PDF_ENABLE_V8
OLDNEW
« no previous file with comments | « no previous file | fpdfsdk/javascript/JS_Object.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698