content/media/webaudio/compiledtest/TestAudioEventTimeline.cpp

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* vim:set ts=2 sw=2 sts=2 et cindent: */
michael@0 3 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 #include "AudioEventTimeline.h"
michael@0 8 #include "TestHarness.h"
michael@0 9 #include <sstream>
michael@0 10 #include <limits>
michael@0 11
michael@0 12 using namespace mozilla;
michael@0 13 using namespace mozilla::dom;
michael@0 14 using std::numeric_limits;
michael@0 15
michael@0 16 // Some simple testing primitives
michael@0 17 void ok(bool val, const char* msg)
michael@0 18 {
michael@0 19 if (val) {
michael@0 20 passed(msg);
michael@0 21 } else {
michael@0 22 fail(msg);
michael@0 23 }
michael@0 24 }
michael@0 25
michael@0 26 namespace std {
michael@0 27
michael@0 28 template <class T>
michael@0 29 basic_ostream<T, char_traits<T> >&
michael@0 30 operator<<(basic_ostream<T, char_traits<T> >& os, nsresult rv)
michael@0 31 {
michael@0 32 os << static_cast<uint32_t>(rv);
michael@0 33 return os;
michael@0 34 }
michael@0 35
michael@0 36 }
michael@0 37
michael@0 38 template <class T, class U>
michael@0 39 void is(const T& a, const U& b, const char* msg)
michael@0 40 {
michael@0 41 std::stringstream ss;
michael@0 42 ss << msg << ", Got: " << a << ", expected: " << b;
michael@0 43 ok(a == b, ss.str().c_str());
michael@0 44 }
michael@0 45
michael@0 46 template <>
michael@0 47 void is(const float& a, const float& b, const char* msg)
michael@0 48 {
michael@0 49 // stupidly high, since we mostly care about the correctness of the algorithm
michael@0 50 const float kEpsilon = 0.00001f;
michael@0 51
michael@0 52 std::stringstream ss;
michael@0 53 ss << msg << ", Got: " << a << ", expected: " << b;
michael@0 54 ok(fabsf(a - b) < kEpsilon, ss.str().c_str());
michael@0 55 }
michael@0 56
michael@0 57 class ErrorResultMock
michael@0 58 {
michael@0 59 public:
michael@0 60 ErrorResultMock()
michael@0 61 : mRv(NS_OK)
michael@0 62 {
michael@0 63 }
michael@0 64 void Throw(nsresult aRv)
michael@0 65 {
michael@0 66 mRv = aRv;
michael@0 67 }
michael@0 68
michael@0 69 operator nsresult() const
michael@0 70 {
michael@0 71 return mRv;
michael@0 72 }
michael@0 73
michael@0 74 ErrorResultMock& operator=(nsresult aRv)
michael@0 75 {
michael@0 76 mRv = aRv;
michael@0 77 return *this;
michael@0 78 }
michael@0 79
michael@0 80 private:
michael@0 81 nsresult mRv;
michael@0 82 };
michael@0 83
michael@0 84 typedef AudioEventTimeline<ErrorResultMock> Timeline;
michael@0 85
michael@0 86 void TestSpecExample()
michael@0 87 {
michael@0 88 // First, run the basic tests
michael@0 89 Timeline timeline(10.0f);
michael@0 90 is(timeline.Value(), 10.0f, "Correct default value returned");
michael@0 91
michael@0 92 ErrorResultMock rv;
michael@0 93
michael@0 94 float curve[] = { -1.0f, 0.0f, 1.0f };
michael@0 95
michael@0 96 // This test is copied from the example in the Web Audio spec
michael@0 97 const double t0 = 0.0,
michael@0 98 t1 = 0.1,
michael@0 99 t2 = 0.2,
michael@0 100 t3 = 0.3,
michael@0 101 t4 = 0.4,
michael@0 102 t5 = 0.6,
michael@0 103 t6 = 0.7,
michael@0 104 t7 = 1.0;
michael@0 105 timeline.SetValueAtTime(0.2f, t0, rv);
michael@0 106 is(rv, NS_OK, "SetValueAtTime succeeded");
michael@0 107 timeline.SetValueAtTime(0.3f, t1, rv);
michael@0 108 is(rv, NS_OK, "SetValueAtTime succeeded");
michael@0 109 timeline.SetValueAtTime(0.4f, t2, rv);
michael@0 110 is(rv, NS_OK, "SetValueAtTime succeeded");
michael@0 111 timeline.LinearRampToValueAtTime(1.0f, t3, rv);
michael@0 112 is(rv, NS_OK, "LinearRampToValueAtTime succeeded");
michael@0 113 timeline.LinearRampToValueAtTime(0.15f, t4, rv);
michael@0 114 is(rv, NS_OK, "LinearRampToValueAtTime succeeded");
michael@0 115 timeline.ExponentialRampToValueAtTime(0.75f, t5, rv);
michael@0 116 is(rv, NS_OK, "ExponentialRampToValueAtTime succeeded");
michael@0 117 timeline.ExponentialRampToValueAtTime(0.05f, t6, rv);
michael@0 118 is(rv, NS_OK, "ExponentialRampToValueAtTime succeeded");
michael@0 119 timeline.SetValueCurveAtTime(curve, ArrayLength(curve), t6, t7 - t6, rv);
michael@0 120 is(rv, NS_OK, "SetValueCurveAtTime succeeded");
michael@0 121
michael@0 122 is(timeline.GetValueAtTime(0.0), 0.2f, "Correct value");
michael@0 123 is(timeline.GetValueAtTime(0.05), 0.2f, "Correct value");
michael@0 124 is(timeline.GetValueAtTime(0.1), 0.3f, "Correct value");
michael@0 125 is(timeline.GetValueAtTime(0.15), 0.3f, "Correct value");
michael@0 126 is(timeline.GetValueAtTime(0.2), 0.4f, "Correct value");
michael@0 127 is(timeline.GetValueAtTime(0.25), (0.4f + 1.0f) / 2, "Correct value");
michael@0 128 is(timeline.GetValueAtTime(0.3), 1.0f, "Correct value");
michael@0 129 is(timeline.GetValueAtTime(0.35), (1.0f + 0.15f) / 2, "Correct value");
michael@0 130 is(timeline.GetValueAtTime(0.4), 0.15f, "Correct value");
michael@0 131 is(timeline.GetValueAtTime(0.45), (0.15f * powf(0.75f / 0.15f, 0.05f / 0.2f)), "Correct value");
michael@0 132 is(timeline.GetValueAtTime(0.5), (0.15f * powf(0.75f / 0.15f, 0.5f)), "Correct value");
michael@0 133 is(timeline.GetValueAtTime(0.55), (0.15f * powf(0.75f / 0.15f, 0.15f / 0.2f)), "Correct value");
michael@0 134 is(timeline.GetValueAtTime(0.6), 0.75f, "Correct value");
michael@0 135 is(timeline.GetValueAtTime(0.65), (0.75f * powf(0.05f / 0.75f, 0.5f)), "Correct value");
michael@0 136 is(timeline.GetValueAtTime(0.7), -1.0f, "Correct value");
michael@0 137 is(timeline.GetValueAtTime(0.9), 0.0f, "Correct value");
michael@0 138 is(timeline.GetValueAtTime(1.0), 1.0f, "Correct value");
michael@0 139 }
michael@0 140
michael@0 141 void TestInvalidEvents()
michael@0 142 {
michael@0 143 static_assert(numeric_limits<float>::has_quiet_NaN, "Platform must have a quiet NaN");
michael@0 144 const float NaN = numeric_limits<float>::quiet_NaN();
michael@0 145 const float Infinity = numeric_limits<float>::infinity();
michael@0 146 Timeline timeline(10.0f);
michael@0 147
michael@0 148 float curve[] = { -1.0f, 0.0f, 1.0f };
michael@0 149 float badCurve1[] = { -1.0f, NaN, 1.0f };
michael@0 150 float badCurve2[] = { -1.0f, Infinity, 1.0f };
michael@0 151 float badCurve3[] = { -1.0f, -Infinity, 1.0f };
michael@0 152
michael@0 153 ErrorResultMock rv;
michael@0 154
michael@0 155 timeline.SetValueAtTime(NaN, 0.1, rv);
michael@0 156 is(rv, NS_ERROR_DOM_SYNTAX_ERR, "Correct error code returned");
michael@0 157 timeline.SetValueAtTime(Infinity, 0.1, rv);
michael@0 158 is(rv, NS_ERROR_DOM_SYNTAX_ERR, "Correct error code returned");
michael@0 159 timeline.SetValueAtTime(-Infinity, 0.1, rv);
michael@0 160 is(rv, NS_ERROR_DOM_SYNTAX_ERR, "Correct error code returned");
michael@0 161 timeline.LinearRampToValueAtTime(NaN, 0.2, rv);
michael@0 162 is(rv, NS_ERROR_DOM_SYNTAX_ERR, "Correct error code returned");
michael@0 163 timeline.LinearRampToValueAtTime(Infinity, 0.2, rv);
michael@0 164 is(rv, NS_ERROR_DOM_SYNTAX_ERR, "Correct error code returned");
michael@0 165 timeline.LinearRampToValueAtTime(-Infinity, 0.2, rv);
michael@0 166 is(rv, NS_ERROR_DOM_SYNTAX_ERR, "Correct error code returned");
michael@0 167 timeline.ExponentialRampToValueAtTime(NaN, 0.3, rv);
michael@0 168 is(rv, NS_ERROR_DOM_SYNTAX_ERR, "Correct error code returned");
michael@0 169 timeline.ExponentialRampToValueAtTime(Infinity, 0.3, rv);
michael@0 170 is(rv, NS_ERROR_DOM_SYNTAX_ERR, "Correct error code returned");
michael@0 171 timeline.ExponentialRampToValueAtTime(-Infinity, 0.4, rv);
michael@0 172 is(rv, NS_ERROR_DOM_SYNTAX_ERR, "Correct error code returned");
michael@0 173 timeline.ExponentialRampToValueAtTime(0, 0.5, rv);
michael@0 174 is(rv, NS_ERROR_DOM_SYNTAX_ERR, "Correct error code returned");
michael@0 175 timeline.SetTargetAtTime(NaN, 0.4, 1.0, rv);
michael@0 176 is(rv, NS_ERROR_DOM_SYNTAX_ERR, "Correct error code returned");
michael@0 177 timeline.SetTargetAtTime(Infinity, 0.4, 1.0, rv);
michael@0 178 is(rv, NS_ERROR_DOM_SYNTAX_ERR, "Correct error code returned");
michael@0 179 timeline.SetTargetAtTime(-Infinity, 0.4, 1.0, rv);
michael@0 180 is(rv, NS_ERROR_DOM_SYNTAX_ERR, "Correct error code returned");
michael@0 181 timeline.SetTargetAtTime(0.4f, NaN, 1.0, rv);
michael@0 182 is(rv, NS_ERROR_DOM_SYNTAX_ERR, "Correct error code returned");
michael@0 183 timeline.SetTargetAtTime(0.4f, Infinity, 1.0, rv);
michael@0 184 is(rv, NS_ERROR_DOM_SYNTAX_ERR, "Correct error code returned");
michael@0 185 timeline.SetTargetAtTime(0.4f, -Infinity, 1.0, rv);
michael@0 186 is(rv, NS_ERROR_DOM_SYNTAX_ERR, "Correct error code returned");
michael@0 187 timeline.SetValueCurveAtTime(nullptr, 0, 1.0, 1.0, rv);
michael@0 188 is(rv, NS_ERROR_DOM_SYNTAX_ERR, "Correct error code returned");
michael@0 189 timeline.SetValueCurveAtTime(badCurve1, ArrayLength(badCurve1), 1.0, 1.0, rv);
michael@0 190 is(rv, NS_ERROR_DOM_SYNTAX_ERR, "Correct error code returned");
michael@0 191 timeline.SetValueCurveAtTime(badCurve2, ArrayLength(badCurve2), 1.0, 1.0, rv);
michael@0 192 is(rv, NS_ERROR_DOM_SYNTAX_ERR, "Correct error code returned");
michael@0 193 timeline.SetValueCurveAtTime(badCurve3, ArrayLength(badCurve3), 1.0, 1.0, rv);
michael@0 194 is(rv, NS_ERROR_DOM_SYNTAX_ERR, "Correct error code returned");
michael@0 195 timeline.SetValueCurveAtTime(curve, ArrayLength(curve), NaN, 1.0, rv);
michael@0 196 is(rv, NS_ERROR_DOM_SYNTAX_ERR, "Correct error code returned");
michael@0 197 timeline.SetValueCurveAtTime(curve, ArrayLength(curve), Infinity, 1.0, rv);
michael@0 198 is(rv, NS_ERROR_DOM_SYNTAX_ERR, "Correct error code returned");
michael@0 199 timeline.SetValueCurveAtTime(curve, ArrayLength(curve), -Infinity, 1.0, rv);
michael@0 200 is(rv, NS_ERROR_DOM_SYNTAX_ERR, "Correct error code returned");
michael@0 201 timeline.SetValueCurveAtTime(curve, ArrayLength(curve), 1.0, NaN, rv);
michael@0 202 is(rv, NS_ERROR_DOM_SYNTAX_ERR, "Correct error code returned");
michael@0 203 timeline.SetValueCurveAtTime(curve, ArrayLength(curve), 1.0, Infinity, rv);
michael@0 204 is(rv, NS_ERROR_DOM_SYNTAX_ERR, "Correct error code returned");
michael@0 205 timeline.SetValueCurveAtTime(curve, ArrayLength(curve), 1.0, -Infinity, rv);
michael@0 206 is(rv, NS_ERROR_DOM_SYNTAX_ERR, "Correct error code returned");
michael@0 207 }
michael@0 208
michael@0 209 void TestEventReplacement()
michael@0 210 {
michael@0 211 Timeline timeline(10.0f);
michael@0 212
michael@0 213 ErrorResultMock rv;
michael@0 214
michael@0 215 is(timeline.GetEventCount(), 0u, "No events yet");
michael@0 216 timeline.SetValueAtTime(10.0f, 0.1, rv);
michael@0 217 is(timeline.GetEventCount(), 1u, "One event scheduled now");
michael@0 218 timeline.SetValueAtTime(20.0f, 0.1, rv);
michael@0 219 is(rv, NS_OK, "Event scheduling should be successful");
michael@0 220 is(timeline.GetEventCount(), 1u, "Event should be replaced");
michael@0 221 is(timeline.GetValueAtTime(0.1), 20.0f, "The first event should be overwritten");
michael@0 222 timeline.LinearRampToValueAtTime(30.0f, 0.1, rv);
michael@0 223 is(rv, NS_OK, "Event scheduling should be successful");
michael@0 224 is(timeline.GetEventCount(), 2u, "Different event type should be appended");
michael@0 225 is(timeline.GetValueAtTime(0.1), 30.0f, "The first event should be overwritten");
michael@0 226 }
michael@0 227
michael@0 228 void TestEventRemoval()
michael@0 229 {
michael@0 230 Timeline timeline(10.0f);
michael@0 231
michael@0 232 ErrorResultMock rv;
michael@0 233
michael@0 234 timeline.SetValueAtTime(10.0f, 0.1, rv);
michael@0 235 timeline.SetValueAtTime(15.0f, 0.15, rv);
michael@0 236 timeline.SetValueAtTime(20.0f, 0.2, rv);
michael@0 237 timeline.LinearRampToValueAtTime(30.0f, 0.3, rv);
michael@0 238 is(timeline.GetEventCount(), 4u, "Should have three events initially");
michael@0 239 timeline.CancelScheduledValues(0.4);
michael@0 240 is(timeline.GetEventCount(), 4u, "Trying to delete past the end of the array should have no effect");
michael@0 241 timeline.CancelScheduledValues(0.3);
michael@0 242 is(timeline.GetEventCount(), 3u, "Should successfully delete one event");
michael@0 243 timeline.CancelScheduledValues(0.12);
michael@0 244 is(timeline.GetEventCount(), 1u, "Should successfully delete two events");
michael@0 245 timeline.CancelAllEvents();
michael@0 246 ok(timeline.HasSimpleValue(), "No event should remain scheduled");
michael@0 247 }
michael@0 248
michael@0 249 void TestBeforeFirstEventSetValue()
michael@0 250 {
michael@0 251 Timeline timeline(10.0f);
michael@0 252
michael@0 253 ErrorResultMock rv;
michael@0 254
michael@0 255 timeline.SetValueAtTime(20.0f, 1.0, rv);
michael@0 256 is(timeline.GetValueAtTime(0.5), 10.0f, "Retrun the default value before the first event");
michael@0 257 }
michael@0 258
michael@0 259 void TestBeforeFirstEventSetTarget()
michael@0 260 {
michael@0 261 Timeline timeline(10.0f);
michael@0 262
michael@0 263 ErrorResultMock rv;
michael@0 264
michael@0 265 timeline.SetTargetAtTime(20.0f, 1.0, 5.0, rv);
michael@0 266 is(timeline.GetValueAtTime(0.5), 10.0f, "Retrun the default value before the first event");
michael@0 267 }
michael@0 268
michael@0 269 void TestBeforeFirstEventLinearRamp()
michael@0 270 {
michael@0 271 Timeline timeline(10.0f);
michael@0 272
michael@0 273 ErrorResultMock rv;
michael@0 274
michael@0 275 timeline.LinearRampToValueAtTime(20.0f, 1.0, rv);
michael@0 276 is(timeline.GetValueAtTime(0.5), 10.0f, "Retrun the default value before the first event");
michael@0 277 }
michael@0 278
michael@0 279 void TestBeforeFirstEventExponentialRamp()
michael@0 280 {
michael@0 281 Timeline timeline(10.0f);
michael@0 282
michael@0 283 ErrorResultMock rv;
michael@0 284
michael@0 285 timeline.ExponentialRampToValueAtTime(20.0f, 1.0, rv);
michael@0 286 is(timeline.GetValueAtTime(0.5), 10.0f, "Retrun the default value before the first event");
michael@0 287 }
michael@0 288
michael@0 289 void TestAfterLastValueEvent()
michael@0 290 {
michael@0 291 Timeline timeline(10.0f);
michael@0 292
michael@0 293 ErrorResultMock rv;
michael@0 294
michael@0 295 timeline.SetValueAtTime(20.0f, 1.0, rv);
michael@0 296 is(timeline.GetValueAtTime(1.5), 20.0f, "Return the last value after the last SetValue event");
michael@0 297 }
michael@0 298
michael@0 299 void TestAfterLastTargetValueEvent()
michael@0 300 {
michael@0 301 Timeline timeline(10.0f);
michael@0 302
michael@0 303 ErrorResultMock rv;
michael@0 304
michael@0 305 timeline.SetTargetAtTime(20.0f, 1.0, 5.0, rv);
michael@0 306 is(timeline.GetValueAtTime(10.), (20.f + (10.f - 20.f) * expf(-9.0f / 5.0f)), "Return the value after the last SetTarget event based on the curve");
michael@0 307 }
michael@0 308
michael@0 309 void TestAfterLastTargetValueEventWithValueSet()
michael@0 310 {
michael@0 311 Timeline timeline(10.0f);
michael@0 312
michael@0 313 ErrorResultMock rv;
michael@0 314
michael@0 315 timeline.SetValue(50.f);
michael@0 316 timeline.SetTargetAtTime(20.0f, 1.0, 5.0, rv);
michael@0 317
michael@0 318 // When using SetTargetValueAtTime, Timeline become stateful: the value for
michael@0 319 // time t may depend on the time t-1, so we can't just query the value at a
michael@0 320 // time and get the right value. We have to call GetValueAtTime for the
michael@0 321 // previous times.
michael@0 322 for (double i = 0.0; i < 9.99; i+=0.01) {
michael@0 323 timeline.GetValueAtTime(i);
michael@0 324 }
michael@0 325
michael@0 326 is(timeline.GetValueAtTime(10.), (20.f + (50.f - 20.f) * expf(-9.0f / 5.0f)), "Return the value after SetValue and the last SetTarget event based on the curve");
michael@0 327 }
michael@0 328
michael@0 329 void TestValue()
michael@0 330 {
michael@0 331 Timeline timeline(10.0f);
michael@0 332
michael@0 333 ErrorResultMock rv;
michael@0 334
michael@0 335 is(timeline.Value(), 10.0f, "value should initially match the default value");
michael@0 336 timeline.SetValue(20.0f);
michael@0 337 is(timeline.Value(), 20.0f, "Should be able to set the value");
michael@0 338 timeline.SetValueAtTime(20.0f, 1.0, rv);
michael@0 339 // TODO: The following check needs to change when we compute the value based on the current time of the context
michael@0 340 is(timeline.Value(), 20.0f, "TODO...");
michael@0 341 timeline.SetValue(30.0f);
michael@0 342 is(timeline.Value(), 20.0f, "Should not be able to set the value");
michael@0 343 }
michael@0 344
michael@0 345 void TestLinearRampAtZero()
michael@0 346 {
michael@0 347 Timeline timeline(10.0f);
michael@0 348
michael@0 349 ErrorResultMock rv;
michael@0 350
michael@0 351 timeline.LinearRampToValueAtTime(20.0f, 0.0, rv);
michael@0 352 is(timeline.GetValueAtTime(0.0), 20.0f, "Should get the correct value when t0 == t1 == 0");
michael@0 353 }
michael@0 354
michael@0 355 void TestExponentialRampAtZero()
michael@0 356 {
michael@0 357 Timeline timeline(10.0f);
michael@0 358
michael@0 359 ErrorResultMock rv;
michael@0 360
michael@0 361 timeline.ExponentialRampToValueAtTime(20.0f, 0.0, rv);
michael@0 362 is(timeline.GetValueAtTime(0.0), 20.0f, "Should get the correct value when t0 == t1 == 0");
michael@0 363 }
michael@0 364
michael@0 365 void TestLinearRampAtSameTime()
michael@0 366 {
michael@0 367 Timeline timeline(10.0f);
michael@0 368
michael@0 369 ErrorResultMock rv;
michael@0 370
michael@0 371 timeline.SetValueAtTime(5.0f, 1.0, rv);
michael@0 372 timeline.LinearRampToValueAtTime(20.0f, 1.0, rv);
michael@0 373 is(timeline.GetValueAtTime(1.0), 20.0f, "Should get the correct value when t0 == t1");
michael@0 374 }
michael@0 375
michael@0 376 void TestExponentialRampAtSameTime()
michael@0 377 {
michael@0 378 Timeline timeline(10.0f);
michael@0 379
michael@0 380 ErrorResultMock rv;
michael@0 381
michael@0 382 timeline.SetValueAtTime(5.0f, 1.0, rv);
michael@0 383 timeline.ExponentialRampToValueAtTime(20.0f, 1.0, rv);
michael@0 384 is(timeline.GetValueAtTime(1.0), 20.0f, "Should get the correct value when t0 == t1");
michael@0 385 }
michael@0 386
michael@0 387 void TestSetTargetZeroTimeConstant()
michael@0 388 {
michael@0 389 Timeline timeline(10.0f);
michael@0 390
michael@0 391 ErrorResultMock rv;
michael@0 392
michael@0 393 timeline.SetTargetAtTime(20.0f, 1.0, 0.0, rv);
michael@0 394 is(timeline.GetValueAtTime(10.), 20.f, "Should get the correct value with timeConstant == 0");
michael@0 395 }
michael@0 396
michael@0 397 void TestExponentialInvalidPreviousZeroValue()
michael@0 398 {
michael@0 399 Timeline timeline(0.f);
michael@0 400
michael@0 401 ErrorResultMock rv;
michael@0 402
michael@0 403 timeline.ExponentialRampToValueAtTime(1.f, 1.0, rv);
michael@0 404 is(rv, NS_ERROR_DOM_SYNTAX_ERR, "Correct error code returned");
michael@0 405 timeline.SetValue(1.f);
michael@0 406 rv = NS_OK;
michael@0 407 timeline.ExponentialRampToValueAtTime(1.f, 1.0, rv);
michael@0 408 is(rv, NS_OK, "Should succeed this time");
michael@0 409 timeline.CancelScheduledValues(0.0);
michael@0 410 is(timeline.GetEventCount(), 0u, "Should have no events scheduled");
michael@0 411 rv = NS_OK;
michael@0 412 timeline.SetValueAtTime(0.f, 0.5, rv);
michael@0 413 is(rv, NS_OK, "Should succeed");
michael@0 414 timeline.ExponentialRampToValueAtTime(1.f, 1.0, rv);
michael@0 415 is(rv, NS_ERROR_DOM_SYNTAX_ERR, "Correct error code returned");
michael@0 416 timeline.CancelScheduledValues(0.0);
michael@0 417 is(timeline.GetEventCount(), 0u, "Should have no events scheduled");
michael@0 418 rv = NS_OK;
michael@0 419 timeline.ExponentialRampToValueAtTime(1.f, 1.0, rv);
michael@0 420 is(rv, NS_OK, "Should succeed this time");
michael@0 421 }
michael@0 422
michael@0 423 int main()
michael@0 424 {
michael@0 425 ScopedXPCOM xpcom("TestAudioEventTimeline");
michael@0 426 if (xpcom.failed()) {
michael@0 427 return 1;
michael@0 428 }
michael@0 429
michael@0 430 TestSpecExample();
michael@0 431 TestInvalidEvents();
michael@0 432 TestEventReplacement();
michael@0 433 TestEventRemoval();
michael@0 434 TestBeforeFirstEventSetValue();
michael@0 435 TestBeforeFirstEventSetTarget();
michael@0 436 TestBeforeFirstEventLinearRamp();
michael@0 437 TestBeforeFirstEventExponentialRamp();
michael@0 438 TestAfterLastValueEvent();
michael@0 439 TestAfterLastTargetValueEvent();
michael@0 440 TestAfterLastTargetValueEventWithValueSet();
michael@0 441 TestValue();
michael@0 442 TestLinearRampAtZero();
michael@0 443 TestExponentialRampAtZero();
michael@0 444 TestLinearRampAtSameTime();
michael@0 445 TestExponentialRampAtSameTime();
michael@0 446 TestSetTargetZeroTimeConstant();
michael@0 447 TestExponentialInvalidPreviousZeroValue();
michael@0 448
michael@0 449 return gFailCount > 0;
michael@0 450 }
michael@0 451

mercurial