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

Unified Diff: remoting/host/it2me/it2me_native_messaging_host_unittest.cc

Issue 1272833002: Pass error messages from native messaging to web-app. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix unit tests. Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: remoting/host/it2me/it2me_native_messaging_host_unittest.cc
diff --git a/remoting/host/it2me/it2me_native_messaging_host_unittest.cc b/remoting/host/it2me/it2me_native_messaging_host_unittest.cc
index fa0b088aa88dd8bb4046e90ddd84c93b29b088d1..251598a5ac33f669a49c0eb879a9e7c7cda45a46 100644
--- a/remoting/host/it2me/it2me_native_messaging_host_unittest.cc
+++ b/remoting/host/it2me/it2me_native_messaging_host_unittest.cc
@@ -17,6 +17,7 @@
#include "net/base/net_util.h"
#include "remoting/base/auto_thread_task_runner.h"
#include "remoting/host/chromoting_host_context.h"
+#include "remoting/host/native_messaging/log_message_handler.h"
#include "remoting/host/native_messaging/native_messaging_pipe.h"
#include "remoting/host/native_messaging/pipe_messaging_channel.h"
#include "remoting/host/policy_watcher.h"
@@ -261,31 +262,38 @@ void It2MeNativeMessagingHostTest::TearDown() {
scoped_ptr<base::DictionaryValue>
It2MeNativeMessagingHostTest::ReadMessageFromOutputPipe() {
- uint32 length;
- int read_result = output_read_file_.ReadAtCurrentPos(
- reinterpret_cast<char*>(&length), sizeof(length));
- if (read_result != sizeof(length)) {
- // The output pipe has been closed, return an empty message.
- return nullptr;
- }
+ while (true) {
+ uint32 length;
+ int read_result = output_read_file_.ReadAtCurrentPos(
+ reinterpret_cast<char*>(&length), sizeof(length));
+ if (read_result != sizeof(length)) {
+ // The output pipe has been closed, return an empty message.
+ return nullptr;
+ }
- std::string message_json(length, '\0');
- read_result = output_read_file_.ReadAtCurrentPos(
- string_as_array(&message_json), length);
- if (read_result != static_cast<int>(length)) {
- LOG(ERROR) << "Message size (" << read_result
- << ") doesn't match the header (" << length << ").";
- return nullptr;
- }
+ std::string message_json(length, '\0');
+ read_result = output_read_file_.ReadAtCurrentPos(
+ string_as_array(&message_json), length);
+ if (read_result != static_cast<int>(length)) {
+ LOG(ERROR) << "Message size (" << read_result
+ << ") doesn't match the header (" << length << ").";
+ return nullptr;
+ }
- scoped_ptr<base::Value> message = base::JSONReader::Read(message_json);
- if (!message || !message->IsType(base::Value::TYPE_DICTIONARY)) {
- LOG(ERROR) << "Malformed message:" << message_json;
- return nullptr;
- }
+ scoped_ptr<base::Value> message = base::JSONReader::Read(message_json);
+ if (!message || !message->IsType(base::Value::TYPE_DICTIONARY)) {
+ LOG(ERROR) << "Malformed message:" << message_json;
+ return nullptr;
+ }
- return make_scoped_ptr(
- static_cast<base::DictionaryValue*>(message.release()));
+ scoped_ptr<base::DictionaryValue> result = make_scoped_ptr(
+ static_cast<base::DictionaryValue*>(message.release()));
+ std::string type;
+ if (!result->GetString("type", &type) ||
Sergey Ulanov 2015/08/20 21:50:20 Add a comment that we are skipping log messages he
Jamie 2015/08/20 22:29:16 Done.
+ type != LogMessageHandler::debug_message_type_name) {
+ return result;
+ }
+ }
}
void It2MeNativeMessagingHostTest::WriteMessageToInputPipe(

Powered by Google App Engine
This is Rietveld 408576698