OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/file_path.h" | 6 #include "base/file_path.h" |
7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
8 #include "chrome/browser/extensions/extension_apitest.h" | 8 #include "chrome/browser/extensions/extension_apitest.h" |
9 #include "chrome/common/chrome_paths.h" | 9 #include "chrome/common/chrome_paths.h" |
10 #include "chrome/common/chrome_switches.h" | 10 #include "chrome/common/chrome_switches.h" |
11 #include "chrome/common/chrome_version_info.h" | 11 #include "chrome/common/chrome_version_info.h" |
12 #include "chrome/common/extensions/features/feature.h" | 12 #include "chrome/common/extensions/features/feature.h" |
13 | 13 |
14 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, NativeMessageBasic) { | 14 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, NativeMessageBasic) { |
15 CommandLine::ForCurrentProcess()->AppendSwitch( | 15 CommandLine::ForCurrentProcess()->AppendSwitch( |
16 switches::kEnableNativeMessaging); | 16 switches::kEnableNativeMessaging); |
| 17 FilePath user_data_dir; |
| 18 ASSERT_TRUE(PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)); |
17 // Override the user data dir to point to our native app. | 19 // Override the user data dir to point to our native app. |
18 extensions::Feature::ScopedCurrentChannel | 20 extensions::Feature::ScopedCurrentChannel |
19 current_channel(chrome::VersionInfo::CHANNEL_DEV); | 21 current_channel(chrome::VersionInfo::CHANNEL_DEV); |
20 FilePath test_user_data_dir; | 22 FilePath test_user_data_dir; |
21 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_user_data_dir)); | 23 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_user_data_dir)); |
22 test_user_data_dir = test_user_data_dir.AppendASCII("native_messaging"); | 24 test_user_data_dir = test_user_data_dir.AppendASCII("native_messaging"); |
23 ASSERT_TRUE(PathService::Override(chrome::DIR_USER_DATA, test_user_data_dir)); | 25 ASSERT_TRUE(PathService::Override(chrome::DIR_USER_DATA, test_user_data_dir)); |
24 ASSERT_TRUE(RunExtensionTest("native_messaging")) << message_; | 26 ASSERT_TRUE(RunExtensionTest("native_messaging")) << message_; |
| 27 // Move the user data dir back. |
| 28 ASSERT_TRUE(PathService::Override(chrome::DIR_USER_DATA, user_data_dir)); |
25 } | 29 } |
OLD | NEW |