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

Unified Diff: chrome/test/data/webui/md_bookmarks/test_store.js

Issue 2735953002: MD Bookmarks: Integrate new data store with UI elements (Closed)
Patch Set: More tweaks Created 3 years, 9 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/webui/md_bookmarks/test_store.js
diff --git a/chrome/test/data/webui/md_bookmarks/test_store.js b/chrome/test/data/webui/md_bookmarks/test_store.js
new file mode 100644
index 0000000000000000000000000000000000000000..28a1ee8591a17eeff50cbdc342dffbef613bd05d
--- /dev/null
+++ b/chrome/test/data/webui/md_bookmarks/test_store.js
@@ -0,0 +1,42 @@
+// Copyright 2017 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.
+
+cr.define('bookmarks', function() {
+ var TestStore = function(data) {
+ this.data = Object.assign(bookmarks.util.createEmptyState(), data);
+ this.actions_ = [];
+ this.observers_ = [];
+ };
+
+ TestStore.prototype = {
+ addObserver: function(client) {
+ this.observers_.push(client);
+ },
+
+ removeObserver: function(client) {},
+
+ isInitialized: function() {
+ return true;
+ },
+
+ handleAction: function(action) {
+ this.actions_.push(action);
calamity 2017/03/09 04:58:57 Is this stack for multi-action UI interactions?
tsergeant 2017/03/09 06:27:55 That's the idea. Nothing ended up needing it, thou
+ },
+
+ get lastAction() {
+ return this.actions_[this.actions_.length - 1];
+ },
+
+ notifyObservers: function() {
+ // For simplicity, we don't want tests to have to worry about modifying
+ // the whole state tree when they want to change a single property. An
+ // alternative is to perform a deep clone in here.
+ this.observers_.forEach((client) => client.onStateChanged(this.data));
calamity 2017/03/09 04:58:57 This might want to explain why a deep copy may be
tsergeant 2017/03/09 06:27:55 Reworded as a TODO. WDYT?
calamity 2017/03/10 03:34:21 Sounds good.
+ },
+ };
+
+ return {
+ TestStore: TestStore,
+ };
+});

Powered by Google App Engine
This is Rietveld 408576698