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

Side by Side Diff: extensions/browser/api/printer_provider/printer_provider_apitest.cc

Issue 925783002: Split ValueSerializer into separate Serializer and Deserializer classes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed cpplint warnings. Created 5 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/json/json_string_value_serializer.h" 6 #include "base/json/json_string_value_serializer.h"
7 #include "base/memory/ref_counted_memory.h" 7 #include "base/memory/ref_counted_memory.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "extensions/browser/api/printer_provider/printer_provider_api.h" 10 #include "extensions/browser/api/printer_provider/printer_provider_api.h"
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 // Validates that set of printers reported by test apps via 205 // Validates that set of printers reported by test apps via
206 // chrome.printerProvider.onGetPritersRequested is the same as the set of 206 // chrome.printerProvider.onGetPritersRequested is the same as the set of
207 // printers in |expected_printers|. |expected_printers| contains list of 207 // printers in |expected_printers|. |expected_printers| contains list of
208 // printer objects formatted as a JSON string. It is assumed that the values 208 // printer objects formatted as a JSON string. It is assumed that the values
209 // in |expoected_printers| are unique. 209 // in |expoected_printers| are unique.
210 void ValidatePrinterListValue( 210 void ValidatePrinterListValue(
211 const base::ListValue& printers, 211 const base::ListValue& printers,
212 const std::vector<std::string>& expected_printers) { 212 const std::vector<std::string>& expected_printers) {
213 ASSERT_EQ(expected_printers.size(), printers.GetSize()); 213 ASSERT_EQ(expected_printers.size(), printers.GetSize());
214 for (size_t i = 0; i < expected_printers.size(); ++i) { 214 for (size_t i = 0; i < expected_printers.size(); ++i) {
215 JSONStringValueSerializer serializer(expected_printers[i]); 215 JSONStringValueDeserializer deserializer(expected_printers[i]);
216 int error_code; 216 int error_code;
217 scoped_ptr<base::Value> printer_value( 217 scoped_ptr<base::Value> printer_value(
218 serializer.Deserialize(&error_code, NULL)); 218 deserializer.Deserialize(&error_code, NULL));
219 ASSERT_TRUE(printer_value) << "Failed to deserialize " 219 ASSERT_TRUE(printer_value) << "Failed to deserialize "
220 << expected_printers[i] << ": " 220 << expected_printers[i] << ": "
221 << "error code " << error_code; 221 << "error code " << error_code;
222 EXPECT_TRUE(printers.Find(*printer_value) != printers.end()) 222 EXPECT_TRUE(printers.Find(*printer_value) != printers.end())
223 << "Unabe to find " << *printer_value << " in " << printers; 223 << "Unabe to find " << *printer_value << " in " << printers;
224 } 224 }
225 } 225 }
226 226
227 private: 227 private:
228 DISALLOW_COPY_AND_ASSIGN(PrinterProviderApiTest); 228 DISALLOW_COPY_AND_ASSIGN(PrinterProviderApiTest);
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
648 &printers, run_loop.QuitClosure())); 648 &printers, run_loop.QuitClosure()));
649 649
650 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); 650 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
651 651
652 run_loop.Run(); 652 run_loop.Run();
653 653
654 EXPECT_TRUE(printers.empty()); 654 EXPECT_TRUE(printers.empty());
655 } 655 }
656 656
657 } // namespace 657 } // namespace
OLDNEW
« no previous file with comments | « extensions/browser/api/printer_provider/printer_provider_api.cc ('k') | extensions/browser/extension_icon_image_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698