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

Side by Side Diff: chrome/test/data/webui/md_bookmarks/test_store.js

Issue 2776993002: [MD Bookmarks] Persist collapsed folders between page loads. (Closed)
Patch Set: fix closure Created 3 years, 8 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 unified diff | Download patch
« no previous file with comments | « chrome/test/data/webui/md_bookmarks/md_bookmarks_browsertest.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 cr.define('bookmarks', function() { 5 cr.define('bookmarks', function() {
6 var TestStore = function(data) { 6 var TestStore = function(data) {
7 this.data = Object.assign(bookmarks.util.createEmptyState(), data); 7 this.data = Object.assign(bookmarks.util.createEmptyState(), data);
8 this.lastAction_ = null; 8 this.lastAction_ = null;
9 this.observers_ = []; 9 this.observers_ = [];
10 this.acceptInit_ = false;
10 }; 11 };
11 12
12 TestStore.prototype = { 13 TestStore.prototype = {
13 addObserver: function(client) { 14 addObserver: function(client) {
14 this.observers_.push(client); 15 this.observers_.push(client);
15 }, 16 },
16 17
17 init: function() {}, 18 init: function(state) {
19 if (this.acceptInit_) {
20 this.data = state;
21 this.acceptInit_ = false;
22 }
23 },
18 24
19 removeObserver: function(client) {}, 25 removeObserver: function(client) {},
20 26
21 isInitialized: function() { 27 isInitialized: function() {
22 return true; 28 return true;
23 }, 29 },
24 30
25 handleAction: function(action) { 31 handleAction: function(action) {
26 this.lastAction_ = action; 32 this.lastAction_ = action;
27 }, 33 },
28 34
29 get lastAction() { 35 get lastAction() {
30 return this.lastAction_; 36 return this.lastAction_;
31 }, 37 },
32 38
33 notifyObservers: function() { 39 notifyObservers: function() {
34 // TODO(tsergeant): Revisit how state modifications work in UI tests. 40 // TODO(tsergeant): Revisit how state modifications work in UI tests.
35 // We don't want tests to worry about modifying the whole state tree. 41 // We don't want tests to worry about modifying the whole state tree.
36 // Instead, we could perform a deep clone in here to ensure that every 42 // Instead, we could perform a deep clone in here to ensure that every
37 // StoreClient is updated. 43 // StoreClient is updated.
38 this.observers_.forEach((client) => client.onStateChanged(this.data)); 44 this.observers_.forEach((client) => client.onStateChanged(this.data));
39 }, 45 },
46
47 // Call in order to accept data from an init call to the TestStore once.
48 acceptInitOnce: function() {
49 this.acceptInit_ = true;
50 },
40 }; 51 };
41 52
42 return { 53 return {
43 TestStore: TestStore, 54 TestStore: TestStore,
44 }; 55 };
45 }); 56 });
OLDNEW
« no previous file with comments | « chrome/test/data/webui/md_bookmarks/md_bookmarks_browsertest.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698