1// Copyright 2013 The Chromium Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5#ifndef CHROME_BROWSER_EXTENSIONS_API_MESSAGING_NATIVE_MESSAGING_TEST_UTIL_H_ 6#define CHROME_BROWSER_EXTENSIONS_API_MESSAGING_NATIVE_MESSAGING_TEST_UTIL_H_ 7 8#include "base/files/scoped_temp_dir.h" 9#include "base/memory/scoped_ptr.h" 10 11#if defined(OS_WIN) 12#include "base/test/test_reg_util_win.h" 13#else 14#include "base/test/scoped_path_override.h" 15#endif 16 17namespace extensions { 18 19// Helper class for native messaging tests. When RegisterTestHost() is called it 20// creates the following manifest files: 21// kHostName ("com.google.chrome.test.echo") - Echo NM host that runs, see 22// chrome/test/data/native_messaging/native_hosts/echo.py . 23// kBinaryMissingHostName ("com.google.chrome.test.host_binary_missing") - 24// Manifest file that points to a nonexistent host binary. 25class ScopedTestNativeMessagingHost { 26 public: 27 static const char kHostName[]; 28 static const char kBinaryMissingHostName[]; 29 static const char kExtensionId[]; 30 31 ScopedTestNativeMessagingHost(); 32 ~ScopedTestNativeMessagingHost(); 33 34 void RegisterTestHost(bool user_level); 35 36 private: 37 base::ScopedTempDir temp_dir_; 38 39#if defined(OS_WIN) 40 registry_util::RegistryOverrideManager registry_override_; 41#else 42 scoped_ptr<base::ScopedPathOverride> path_override_; 43#endif 44 45 DISALLOW_COPY_AND_ASSIGN(ScopedTestNativeMessagingHost); 46}; 47 48} // namespace extensions 49 50#endif // CHROME_BROWSER_EXTENSIONS_API_MESSAGING_NATIVE_MESSAGING_TEST_UTIL_H_ 51