Chromium Code Reviews| Index: chrome/test/data/extensions/api_test/instance_id/get_creation_time/get_creation_time.js |
| diff --git a/chrome/test/data/extensions/api_test/instance_id/get_creation_time/get_creation_time.js b/chrome/test/data/extensions/api_test/instance_id/get_creation_time/get_creation_time.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..4e29a4129b60bb3153fafd31384f9b8dfda3aa46 |
| --- /dev/null |
| +++ b/chrome/test/data/extensions/api_test/instance_id/get_creation_time/get_creation_time.js |
| @@ -0,0 +1,57 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +function getCreationTimeWithoutCallback() { |
| + try { |
| + chrome.instanceID.getCreationTime(); |
| + chrome.test.fail( |
| + "Calling getCreationTime without callback should fail."); |
| + } catch (e) { |
| + chrome.test.succeed(); |
| + }; |
| +} |
| + |
| +function getCreationTimeBeforeGetID() { |
| + chrome.instanceID.getCreationTime(function(creationTime) { |
| + if (chrome.runtime.lastError) { |
| + chrome.test.fail( |
| + "chrome.runtime.lastError: " + chrome.runtime.lastError.message); |
| + return; |
| + } |
| + if (creationTime) { |
| + chrome.test.fail("Creation time should be zero."); |
| + return; |
| + } |
| + |
| + chrome.test.succeed(); |
| + }); |
| +} |
| + |
| +function getCreationTimeAfterGetID() { |
| + chrome.instanceID.getID(function(id) { |
| + if (!id) { |
| + chrome.test.fail("ID should not be zero."); |
| + return; |
| + } |
| + chrome.instanceID.getCreationTime(function(creationTime) { |
| + if (chrome.runtime.lastError) { |
| + chrome.test.fail( |
| + "chrome.runtime.lastError: " + chrome.runtime.lastError.message); |
| + return; |
| + } |
| + if (!creationTime) { |
| + chrome.test.fail("Creation time should not be zero."); |
| + return; |
| + } |
| + |
| + chrome.test.succeed(); |
| + }); |
| + }); |
| +} |
| + |
| +chrome.test.runTests([ |
| + getCreationTimeWithoutCallback, |
| + getCreationTimeBeforeGetID, |
| + getCreationTimeAfterGetID, |
|
fgorski
2015/05/07 19:59:53
how about a test for getting creation time after I
jianli
2015/05/07 20:47:01
ditto.
|
| +]); |