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

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

Issue 12386018: Revert 185189. (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
Index: chrome/browser/extensions/api/messaging/native_messaging_apitest.cc
===================================================================
--- chrome/browser/extensions/api/messaging/native_messaging_apitest.cc (revision 185206)
+++ chrome/browser/extensions/api/messaging/native_messaging_apitest.cc (working copy)
@@ -4,61 +4,22 @@
#include "base/command_line.h"
#include "base/files/file_path.h"
-#include "base/files/scoped_temp_dir.h"
-#include "base/json/json_file_value_serializer.h"
#include "base/path_service.h"
-#include "base/stringprintf.h"
#include "chrome/browser/extensions/extension_apitest.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/chrome_version_info.h"
#include "chrome/common/extensions/features/feature.h"
-namespace {
-
-const char kHostName[] = "com.google.chrome.test.echo";
-
-void CreateTestManifestFile(base::FilePath manifest_path) {
- scoped_ptr<base::DictionaryValue> manifest(new base::DictionaryValue());
- manifest->SetString("name", kHostName);
- 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("chrome-extension://knldjmfmopnpolahpmmgbagdohdnhkik/");
- manifest->Set("allowed_origins", origins.release());
-
- JSONFileValueSerializer serializer(manifest_path);
- ASSERT_TRUE(serializer.Serialize(*manifest));
-}
-
-} // namespace
-
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, NativeMessageBasic) {
- base::ScopedTempDir temp_dir;
- base::FilePath manifest_path =
- temp_dir.path().AppendASCII(std::string(kHostName) + ".json");
-
- ASSERT_NO_FATAL_FAILURE(CreateTestManifestFile(manifest_path));
-
CommandLine::ForCurrentProcess()->AppendSwitch(
switches::kEnableNativeMessaging);
-
- std::string hosts_option = base::StringPrintf(
- "%s=%s", kHostName, manifest_path.AsUTF8Unsafe().c_str());
- CommandLine::ForCurrentProcess()->AppendSwitchASCII(
- switches::kNativeMessagingHosts, hosts_option);
-
+ // Override the user data dir to point to our native app.
+ extensions::Feature::ScopedCurrentChannel
+ current_channel(chrome::VersionInfo::CHANNEL_DEV);
+ 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");
+ ASSERT_TRUE(PathService::Override(chrome::DIR_USER_DATA, test_user_data_dir));
ASSERT_TRUE(RunExtensionTest("native_messaging")) << message_;
}

Powered by Google App Engine
This is Rietveld 408576698