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, |
+ }; |
+}); |