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

Side by Side Diff: components/sync/engine_impl/js_mutation_event_observer_unittest.cc

Issue 2889163002: Remove raw DictionaryValue::Set in //components (Closed)
Patch Set: Nits Created 3 years, 6 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "components/sync/engine_impl/js_mutation_event_observer.h" 5 #include "components/sync/engine_impl/js_mutation_event_observer.h"
6 6
7 #include <utility>
8
9 #include "base/memory/ptr_util.h"
7 #include "base/run_loop.h" 10 #include "base/run_loop.h"
8 #include "base/test/scoped_task_environment.h" 11 #include "base/test/scoped_task_environment.h"
9 #include "base/values.h" 12 #include "base/values.h"
10 #include "components/sync/base/model_type.h" 13 #include "components/sync/base/model_type.h"
11 #include "components/sync/js/js_event_details.h" 14 #include "components/sync/js/js_event_details.h"
12 #include "components/sync/js/js_test_util.h" 15 #include "components/sync/js/js_test_util.h"
13 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
14 17
15 namespace syncer { 18 namespace syncer {
16 namespace { 19 namespace {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 // For each i, we call OnChangesApplied() with the first arg equal 65 // For each i, we call OnChangesApplied() with the first arg equal
63 // to i cast to ModelType and the second argument with the changes 66 // to i cast to ModelType and the second argument with the changes
64 // starting from changes[i]. 67 // starting from changes[i].
65 68
66 // Set expectations for each data type. 69 // Set expectations for each data type.
67 for (int i = AUTOFILL_PROFILE; i < MODEL_TYPE_COUNT; ++i) { 70 for (int i = AUTOFILL_PROFILE; i < MODEL_TYPE_COUNT; ++i) {
68 const std::string& model_type_str = ModelTypeToString(ModelTypeFromInt(i)); 71 const std::string& model_type_str = ModelTypeToString(ModelTypeFromInt(i));
69 base::DictionaryValue expected_details; 72 base::DictionaryValue expected_details;
70 expected_details.SetString("modelType", model_type_str); 73 expected_details.SetString("modelType", model_type_str);
71 expected_details.SetString("writeTransactionId", "0"); 74 expected_details.SetString("writeTransactionId", "0");
72 base::ListValue* expected_changes = new base::ListValue(); 75 auto expected_changes = base::MakeUnique<base::ListValue>();
73 expected_details.Set("changes", expected_changes);
74 for (int j = i; j < MODEL_TYPE_COUNT; ++j) { 76 for (int j = i; j < MODEL_TYPE_COUNT; ++j) {
75 expected_changes->Append(changes[j].ToValue()); 77 expected_changes->Append(changes[j].ToValue());
76 } 78 }
79 expected_details.Set("changes", std::move(expected_changes));
77 EXPECT_CALL(mock_js_event_handler_, 80 EXPECT_CALL(mock_js_event_handler_,
78 HandleJsEvent("onChangesApplied", 81 HandleJsEvent("onChangesApplied",
79 HasDetailsAsDictionary(expected_details))); 82 HasDetailsAsDictionary(expected_details)));
80 } 83 }
81 84
82 // Fire OnChangesApplied() for each data type. 85 // Fire OnChangesApplied() for each data type.
83 for (int i = AUTOFILL_PROFILE; i < MODEL_TYPE_COUNT; ++i) { 86 for (int i = AUTOFILL_PROFILE; i < MODEL_TYPE_COUNT; ++i) {
84 ChangeRecordList local_changes(changes + i, changes + arraysize(changes)); 87 ChangeRecordList local_changes(changes + i, changes + arraysize(changes));
85 js_mutation_event_observer_.OnChangesApplied( 88 js_mutation_event_observer_.OnChangesApplied(
86 ModelTypeFromInt(i), 0, ImmutableChangeRecordList(&local_changes)); 89 ModelTypeFromInt(i), 0, ImmutableChangeRecordList(&local_changes));
(...skipping 15 matching lines...) Expand all
102 } 105 }
103 106
104 for (int i = FIRST_REAL_MODEL_TYPE; i < MODEL_TYPE_COUNT; ++i) { 107 for (int i = FIRST_REAL_MODEL_TYPE; i < MODEL_TYPE_COUNT; ++i) {
105 js_mutation_event_observer_.OnChangesComplete(ModelTypeFromInt(i)); 108 js_mutation_event_observer_.OnChangesComplete(ModelTypeFromInt(i));
106 } 109 }
107 PumpLoop(); 110 PumpLoop();
108 } 111 }
109 112
110 } // namespace 113 } // namespace
111 } // namespace syncer 114 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698