Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11342)

Unified Diff: chrome/test/data/extensions/api_test/instance_id/get_creation_time/get_creation_time.js

Issue 1128123003: Implement InstanceID API functions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix test Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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,
+]);

Powered by Google App Engine
This is Rietveld 408576698