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

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: 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/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..501c982cd6cebd0a957229e7e79fd49d34359ded 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,34 @@ 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 (!result->GetString("type", &type) ||
+ type != LogMessageHandler::debug_message_type_name) {
+ 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(

Powered by Google App Engine
This is Rietveld 408576698