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

Unified Diff: third_party/WebKit/LayoutTests/http/tests/budget/budget-service-mock.js

Issue 2231873002: Added budget_service.mojom (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@budget_api
Patch Set: Fixed crash, all tests working Created 4 years, 4 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: third_party/WebKit/LayoutTests/http/tests/budget/budget-service-mock.js
diff --git a/third_party/WebKit/LayoutTests/http/tests/budget/budget-service-mock.js b/third_party/WebKit/LayoutTests/http/tests/budget/budget-service-mock.js
new file mode 100644
index 0000000000000000000000000000000000000000..cb51bcffd224e89a941ef843d73e720ee94f5ac0
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/budget/budget-service-mock.js
@@ -0,0 +1,43 @@
+/**
+ * Mock implementation of the budget service.
+ */
+
+"use strict";
+
+const TEST_BUDGET_COST = 1.2;
+const TEST_BUDGET_VALUE = 2.3;
johnme 2016/08/17 13:54:01 Nit: value -> available?
harkness 2016/08/18 10:23:26 Done.
+const TEST_BUDGET_EXPIRATION = 3.4;
johnme 2016/08/17 13:54:01 Whilst 3 milliseconds past midnight 1970 is a vali
harkness 2016/08/18 10:23:26 Done.
+
+let budgetServiceMock = loadMojoModules(
+ 'budgetServiceMock',
+ ['third_party/WebKit/public/platform/modules/budget_service/budget_service.mojom',
+ 'mojo/public/js/router']
+ ).then(mojo => {
johnme 2016/08/17 13:54:01 Nit: please move the ] down next to the )
harkness 2016/08/18 10:23:26 Done.
+ let [budget_service, router] = mojo.modules;
johnme 2016/08/17 13:54:01 Nit: camelCase in JS
harkness 2016/08/18 10:23:26 budget_service is the name of the mojo service, so
johnme 2016/08/18 13:04:31 geolocation-mock.js calls one of its loaded mojo s
harkness 2016/08/22 08:57:47 Sounds good, I'll change it.
+
+ class BudgetServiceMock {
+ constructor(interfaceProvider) {
+ interfaceProvider.addInterfaceOverrideForTesting(
+ budget_service.BudgetService.name,
+ handle => this.connectBudgetService_(handle));
+
+ this.interfaceProvider_ = interfaceProvider;
+ }
+
+ connectBudgetService_(handle) {
+ this.budgetServiceStub_ = new budget_service.BudgetService.stubClass(this);
+ this.budgetServiceRouter_ = new router.Router(handle);
+ this.budgetServiceRouter_.setIncomingReceiver(this.budgetServiceStub_);
+ }
+
+ getCost(operationType) {
+ return Promise.resolve({ cost:TEST_BUDGET_COST });
+ }
+
+ getBudget() {
+ return Promise.resolve({ budget: [ { time:TEST_BUDGET_EXPIRATION, budget_at:TEST_BUDGET_VALUE } ] });
+ }
+ }
+ // Connect to the Mojo interface.
+ return new BudgetServiceMock(mojo.interfaces);
+});

Powered by Google App Engine
This is Rietveld 408576698