summaryrefslogtreecommitdiff
path: root/testing/embedder_test_timer_handling_delegate.h
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2015-11-04 16:02:47 -0800
committerLei Zhang <thestig@chromium.org>2015-11-04 16:02:47 -0800
commit79e893a1d0f2083f17c40ccadf2cc1250aad5a14 (patch)
tree114028fbcc6ba016620cba2981a512bea83128d5 /testing/embedder_test_timer_handling_delegate.h
parent8fec3e42ed57a988ad5e7faae5e6a83847a3267e (diff)
downloadpdfium-79e893a1d0f2083f17c40ccadf2cc1250aad5a14.tar.xz
Merge to XFA: Make JS app.setTimeOut() work again.
This regressed in commit 794c9b6. BUG=551248 TBR=tsepez@chromium.org Review URL: https://codereview.chromium.org/1424743006 . (cherry picked from commit 8cadf995e9a0fec8da19f69edac9d10fccca7eed) (cherry picked from commit 955930dce7e4b5c764cdd34b134baea4207de523) Review URL: https://codereview.chromium.org/1416663008 .
Diffstat (limited to 'testing/embedder_test_timer_handling_delegate.h')
-rw-r--r--testing/embedder_test_timer_handling_delegate.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/testing/embedder_test_timer_handling_delegate.h b/testing/embedder_test_timer_handling_delegate.h
index aca4ac1b77..74e346e830 100644
--- a/testing/embedder_test_timer_handling_delegate.h
+++ b/testing/embedder_test_timer_handling_delegate.h
@@ -6,12 +6,39 @@
#define TESTING_EMBEDDER_TEST_TIMER_HANDLING_DELEGATE_H_
#include <map>
+#include <string>
#include <utility>
+#include <vector>
#include "embedder_test.h"
+#include "test_support.h"
class EmbedderTestTimerHandlingDelegate : public EmbedderTest::Delegate {
public:
+ struct ReceivedAlert {
+ ReceivedAlert(FPDF_WIDESTRING message_in,
+ FPDF_WIDESTRING title_in,
+ int type_in,
+ int icon_in)
+ : type(type_in), icon(icon_in) {
+ message = GetWideString(message_in);
+ title = GetWideString(title_in);
+ }
+
+ std::wstring message;
+ std::wstring title;
+ int type;
+ int icon;
+ };
+
+ int Alert(FPDF_WIDESTRING message,
+ FPDF_WIDESTRING title,
+ int type,
+ int icon) override {
+ alerts_.push_back(ReceivedAlert(message, title, type, icon));
+ return 0;
+ }
+
int SetTimer(int msecs, TimerCallback fn) override {
expiry_to_timer_map_.insert(std::pair<int, Timer>(
msecs + imaginary_elapsed_msecs_, Timer(++next_timer_id_, fn)));
@@ -44,11 +71,14 @@ class EmbedderTestTimerHandlingDelegate : public EmbedderTest::Delegate {
}
}
+ const std::vector<ReceivedAlert>& GetAlerts() const { return alerts_; }
+
protected:
using Timer = std::pair<int, TimerCallback>; // ID, callback pair.
std::multimap<int, Timer> expiry_to_timer_map_; // Keyed by timeout.
int next_timer_id_ = 0;
int imaginary_elapsed_msecs_ = 0;
+ std::vector<ReceivedAlert> alerts_;
};
#endif // TESTING_EMBEDDER_TEST_TIMER_HANDLING_DELEGATE_H_