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

Unified Diff: remoting/host/setup/me2me_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: Reviewer feedback. 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
« no previous file with comments | « remoting/host/setup/me2me_native_messaging_host.cc ('k') | remoting/remoting_host_srcs.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/host/setup/me2me_native_messaging_host_unittest.cc
diff --git a/remoting/host/setup/me2me_native_messaging_host_unittest.cc b/remoting/host/setup/me2me_native_messaging_host_unittest.cc
index 922f9965c0ba68053b59e9a6dca10f3cead28c31..e973d7d178a169a79560ce578a9d5d14e8869724 100644
--- a/remoting/host/setup/me2me_native_messaging_host_unittest.cc
+++ b/remoting/host/setup/me2me_native_messaging_host_unittest.cc
@@ -17,6 +17,7 @@
#include "net/base/file_stream.h"
#include "net/base/net_util.h"
#include "remoting/base/auto_thread_task_runner.h"
+#include "remoting/host/native_messaging/log_message_handler.h"
#include "remoting/host/native_messaging/pipe_messaging_channel.h"
#include "remoting/host/pin_hash.h"
#include "remoting/host/setup/mock_oauth_client.h"
@@ -383,27 +384,35 @@ void Me2MeNativeMessagingHostTest::TearDown() {
scoped_ptr<base::DictionaryValue>
Me2MeNativeMessagingHostTest::ReadMessageFromOutputPipe() {
- uint32 length;
- int read_result = output_read_file_.ReadAtCurrentPos(
- reinterpret_cast<char*>(&length), sizeof(length));
- if (read_result != sizeof(length)) {
- return nullptr;
+ while (true) {
+ uint32 length;
+ int read_result = output_read_file_.ReadAtCurrentPos(
+ reinterpret_cast<char*>(&length), sizeof(length));
+ if (read_result != sizeof(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)) {
+ return nullptr;
+ }
+
+ scoped_ptr<base::Value> message = base::JSONReader::Read(message_json);
+ if (!message || !message->IsType(base::Value::TYPE_DICTIONARY)) {
+ return nullptr;
+ }
+
+ scoped_ptr<base::DictionaryValue> result = make_scoped_ptr(
+ static_cast<base::DictionaryValue*>(message.release()));
+ std::string type;
+ // If this is a debug message log, ignore it, otherwise return it.
+ if (!result->GetString("type", &type) ||
+ type != LogMessageHandler::kDebugMessageTypeName) {
+ return result;
+ }
}
-
- 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)) {
- return nullptr;
- }
-
- scoped_ptr<base::Value> message = base::JSONReader::Read(message_json);
- if (!message || !message->IsType(base::Value::TYPE_DICTIONARY)) {
- return nullptr;
- }
-
- return make_scoped_ptr(
- static_cast<base::DictionaryValue*>(message.release()));
}
void Me2MeNativeMessagingHostTest::WriteMessageToInputPipe(
« no previous file with comments | « remoting/host/setup/me2me_native_messaging_host.cc ('k') | remoting/remoting_host_srcs.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698