OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2006-2008 The Chromium 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 #ifndef WEBKIT_GLUE_PLUGINS_TEST_PLUGIN_SCHEDULE_TIMER_TEST_H |
| 6 #define WEBKIT_GLUE_PLUGINS_TEST_PLUGIN_SCHEDULE_TIMER_TEST_H |
| 7 |
| 8 #include <vector> |
| 9 |
| 10 #include "base/at_exit.h" |
| 11 #include "base/time.h" |
| 12 #include "webkit/glue/plugins/test/plugin_test.h" |
| 13 |
| 14 namespace NPAPIClient { |
| 15 |
| 16 // This class tests scheduling and unscheduling of timers using |
| 17 // NPN_ScheduleTimer and NPN_UnscheduleTimer. |
| 18 class ScheduleTimerTest : public PluginTest { |
| 19 public: |
| 20 ScheduleTimerTest(NPP id, NPNetscapeFuncs *host_functions); |
| 21 |
| 22 virtual NPError New(uint16 mode, int16 argc, const char* argn[], |
| 23 const char* argv[], NPSavedData* saved); |
| 24 |
| 25 void OnTimer(uint32 timer_id); |
| 26 |
| 27 private: |
| 28 // base::Time needs one of these. |
| 29 base::AtExitManager at_exit_manager_; |
| 30 |
| 31 // Table mapping timer index (as used in event schedule) to timer id. |
| 32 static const int kNumTimers = 3; |
| 33 uint32 timer_ids_[kNumTimers]; |
| 34 |
| 35 // Schedule of events for test. |
| 36 static const int kNumEvents = 11; |
| 37 struct Event { |
| 38 int time; |
| 39 |
| 40 // The index of the timer that triggered the event or -1 for the first |
| 41 // event. |
| 42 int received_index; |
| 43 |
| 44 // The index of the timer to schedule on this event or -1. |
| 45 int scheduled_index; |
| 46 |
| 47 // Info about the timer to be scheduled (if any). |
| 48 uint32 scheduled_interval; |
| 49 bool schedule_repeated; |
| 50 |
| 51 // The index of the timer to unschedule on this event or -1. |
| 52 int unscheduled_index; |
| 53 }; |
| 54 static Event schedule_[kNumEvents]; |
| 55 int num_received_events_; |
| 56 |
| 57 // Set of events that have been received (by index). |
| 58 bool received_events_[kNumEvents]; |
| 59 |
| 60 // Time of initial event. |
| 61 base::Time start_time_; |
| 62 |
| 63 // Returns index of matching unreceived event or -1 if not found. |
| 64 int FindUnreceivedEvent(int time, uint32 timer_id); |
| 65 void HandleEvent(int event_index); |
| 66 }; |
| 67 |
| 68 } // namespace NPAPIClient |
| 69 |
| 70 #endif // WEBKIT_GLUE_PLUGINS_TEST_PLUGIN_SCHEDULE_TIMER_TEST_H |
OLD | NEW |