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

Side by Side Diff: remoting/host/it2me/it2me_native_messaging_host_unittest.cc

Issue 2539363004: Make base::Value::TYPE a scoped enum. (Closed)
Patch Set: Rebase Created 4 years 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "remoting/host/it2me/it2me_native_messaging_host.h" 5 #include "remoting/host/it2me/it2me_native_messaging_host.h"
6 6
7 #include <cstdint> 7 #include <cstdint>
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 std::string message_json(length, '\0'); 353 std::string message_json(length, '\0');
354 read_result = output_read_file_.ReadAtCurrentPos( 354 read_result = output_read_file_.ReadAtCurrentPos(
355 base::string_as_array(&message_json), length); 355 base::string_as_array(&message_json), length);
356 if (read_result != static_cast<int>(length)) { 356 if (read_result != static_cast<int>(length)) {
357 LOG(ERROR) << "Message size (" << read_result 357 LOG(ERROR) << "Message size (" << read_result
358 << ") doesn't match the header (" << length << ")."; 358 << ") doesn't match the header (" << length << ").";
359 return nullptr; 359 return nullptr;
360 } 360 }
361 361
362 std::unique_ptr<base::Value> message = base::JSONReader::Read(message_json); 362 std::unique_ptr<base::Value> message = base::JSONReader::Read(message_json);
363 if (!message || !message->IsType(base::Value::TYPE_DICTIONARY)) { 363 if (!message || !message->IsType(base::Value::Type::DICTIONARY)) {
364 LOG(ERROR) << "Malformed message:" << message_json; 364 LOG(ERROR) << "Malformed message:" << message_json;
365 return nullptr; 365 return nullptr;
366 } 366 }
367 367
368 std::unique_ptr<base::DictionaryValue> result = base::WrapUnique( 368 std::unique_ptr<base::DictionaryValue> result = base::WrapUnique(
369 static_cast<base::DictionaryValue*>(message.release())); 369 static_cast<base::DictionaryValue*>(message.release()));
370 std::string type; 370 std::string type;
371 // If this is a debug message log, ignore it, otherwise return it. 371 // If this is a debug message log, ignore it, otherwise return it.
372 if (!result->GetString("type", &type) || 372 if (!result->GetString("type", &type) ||
373 type != LogMessageHandler::kDebugMessageTypeName) { 373 type != LogMessageHandler::kDebugMessageTypeName) {
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
632 } 632 }
633 633
634 // Verify rejection if type is unrecognized. 634 // Verify rejection if type is unrecognized.
635 TEST_F(It2MeNativeMessagingHostTest, InvalidType) { 635 TEST_F(It2MeNativeMessagingHostTest, InvalidType) {
636 base::DictionaryValue message; 636 base::DictionaryValue message;
637 message.SetString("type", "xxx"); 637 message.SetString("type", "xxx");
638 TestBadRequest(message, true); 638 TestBadRequest(message, true);
639 } 639 }
640 640
641 } // namespace remoting 641 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/it2me/it2me_native_messaging_host.cc ('k') | remoting/host/pairing_registry_delegate_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698