prefixedmechanism_test.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. // Copyright 2011 The Closure Library Authors. All Rights Reserved.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS-IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. goog.provide('goog.storage.mechanism.PrefixedMechanismTest');
  15. goog.setTestOnly('goog.storage.mechanism.PrefixedMechanismTest');
  16. goog.require('goog.storage.mechanism.HTML5LocalStorage');
  17. goog.require('goog.storage.mechanism.PrefixedMechanism');
  18. /** @suppress {extraRequire} */
  19. goog.require('goog.storage.mechanism.mechanismSeparationTester');
  20. /** @suppress {extraRequire} */
  21. goog.require('goog.storage.mechanism.mechanismSharingTester');
  22. goog.require('goog.testing.jsunit');
  23. var submechanism = null;
  24. function setUp() {
  25. submechanism = new goog.storage.mechanism.HTML5LocalStorage();
  26. if (submechanism.isAvailable()) {
  27. mechanism =
  28. new goog.storage.mechanism.PrefixedMechanism(submechanism, 'test');
  29. mechanism_shared =
  30. new goog.storage.mechanism.PrefixedMechanism(submechanism, 'test');
  31. mechanism_separate =
  32. new goog.storage.mechanism.PrefixedMechanism(submechanism, 'test2');
  33. }
  34. }
  35. function tearDown() {
  36. if (!!mechanism) {
  37. mechanism.clear();
  38. mechanism = null;
  39. }
  40. if (!!mechanism_shared) {
  41. mechanism_shared.clear();
  42. mechanism_shared = null;
  43. }
  44. if (!!mechanism_separate) {
  45. mechanism_separate.clear();
  46. mechanism_separate = null;
  47. }
  48. }
  49. function testAvailability() {
  50. if (submechanism.isAvailable()) {
  51. assertNotNull(mechanism);
  52. assertNotNull(mechanism_shared);
  53. assertNotNull(mechanism_separate);
  54. }
  55. }