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

Unified Diff: chrome/browser/extensions/api/messaging/native_messaging_test_util.cc

Issue 12374054: Update and enable NativeMessagingTest.EchoConnect. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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 | « chrome/browser/extensions/api/messaging/native_messaging_test_util.h ('k') | chrome/chrome_tests_unit.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/api/messaging/native_messaging_test_util.cc
diff --git a/chrome/browser/extensions/api/messaging/native_messaging_test_util.cc b/chrome/browser/extensions/api/messaging/native_messaging_test_util.cc
new file mode 100644
index 0000000000000000000000000000000000000000..d7ba0f291fa18940c4929f924d3109c6a8bc8db2
--- /dev/null
+++ b/chrome/browser/extensions/api/messaging/native_messaging_test_util.cc
@@ -0,0 +1,48 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/extensions/api/messaging/native_messaging_test_util.h"
+
+#include "base/files/file_path.h"
+#include "base/json/json_file_value_serializer.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/path_service.h"
+#include "base/stringprintf.h"
+#include "base/values.h"
+#include "chrome/common/chrome_paths.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace extensions {
+
+const char kTestNativeMessagingHostName[] = "com.google.chrome.test.echo";
+const char kTestNativeMessagingExtensionId[] =
+ "knldjmfmopnpolahpmmgbagdohdnhkik";
+
+void CreateTestNativeHostManifest(base::FilePath manifest_path) {
+ scoped_ptr<base::DictionaryValue> manifest(new base::DictionaryValue());
+ manifest->SetString("name", kTestNativeMessagingHostName);
+ manifest->SetString("description", "Native Messaging Echo Test");
+ manifest->SetString("type", "stdio");
+
+ base::FilePath test_user_data_dir;
+ ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_user_data_dir));
+ test_user_data_dir = test_user_data_dir.AppendASCII("native_messaging");
+ test_user_data_dir = test_user_data_dir.AppendASCII("native_hosts");
+#ifdef OS_POSIX
+ base::FilePath host_path = test_user_data_dir.AppendASCII("echo.py");
+#else
+ base::FilePath host_path = test_user_data_dir.AppendASCII("echo.bat");
+#endif
+ manifest->SetString("path", host_path.AsUTF8Unsafe());
+
+ scoped_ptr<base::ListValue> origins(new base::ListValue());
+ origins->AppendString(base::StringPrintf("chrome-extension://%s/",
+ kTestNativeMessagingExtensionId));
+ manifest->Set("allowed_origins", origins.release());
+
+ JSONFileValueSerializer serializer(manifest_path);
+ ASSERT_TRUE(serializer.Serialize(*manifest));
+}
+
+} // namespace extensions
« no previous file with comments | « chrome/browser/extensions/api/messaging/native_messaging_test_util.h ('k') | chrome/chrome_tests_unit.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698