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

Unified Diff: chrome/browser/printing/cloud_print/test/cloud_print_proxy_process_browsertest.cc

Issue 9131016: Cloud Print Policy - service side enforcement, Mac browser tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleanup Created 8 years, 11 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 | « no previous file | chrome/chrome_tests.gypi » ('j') | chrome/common/mac/mock_launchd.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/printing/cloud_print/test/cloud_print_proxy_process_browsertest.cc
diff --git a/chrome/browser/printing/cloud_print/test/cloud_print_proxy_process_browsertest.cc b/chrome/browser/printing/cloud_print/test/cloud_print_proxy_process_browsertest.cc
index 8c6879a819f972555069ce9e9a80a82f4ce43365..5fe59747bcb206b98b452fac5293cb77163cf1d3 100644
--- a/chrome/browser/printing/cloud_print/test/cloud_print_proxy_process_browsertest.cc
+++ b/chrome/browser/printing/cloud_print/test/cloud_print_proxy_process_browsertest.cc
@@ -19,7 +19,6 @@
#include "chrome/browser/profiles/profile_keyed_service.h"
#include "chrome/browser/service/service_process_control.h"
#include "chrome/browser/ui/browser_init.h"
-#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/service_messages.h"
@@ -40,6 +39,9 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/multiprocess_func_list.h"
+#if defined(OS_MACOSX)
+#include "chrome/common/mac/mock_launchd.h"
+#endif
#if defined(OS_POSIX)
#include "base/global_descriptors_posix.h"
#endif
@@ -57,6 +59,10 @@ using ::testing::_;
namespace {
+#if defined(OS_MACOSX)
+const char kTestExecutablePath[] = "test-executable-path";
+#endif
+
bool g_good_shutdown = false;
void ShutdownTask() {
@@ -186,8 +192,19 @@ int CloudPrintMockService_Main(SetExpectationsCallback set_expectations) {
MessageLoopForUI main_message_loop;
main_message_loop.set_thread_name("Main Thread");
+#if defined(OS_MACOSX)
+ CommandLine* cl = CommandLine::ForCurrentProcess();
+ FilePath executable_path = cl->GetSwitchValuePath(kTestExecutablePath);
Albert Bodenhamer 2012/01/20 20:34:19 I've seen crashes resulting from calling GetSwitch
Scott Byer 2012/01/20 23:13:37 Added an error return instead, though I'm surprise
+ EXPECT_NE(std::string(), executable_path.value());
Mark Mentovai 2012/01/20 20:41:35 EXPECT_FALSE(executable_path.value().empty()) is m
Scott Byer 2012/01/20 23:13:37 Done.
+ MockLaunchd mock_launchd(executable_path, &main_message_loop, true, true);
+ Launchd::ScopedInstance use_mock(&mock_launchd);
+#endif
+
ServiceProcessState* state(new ServiceProcessState);
- EXPECT_TRUE(state->Initialize());
+ bool service_process_state_initialized = state->Initialize();
+ EXPECT_TRUE(service_process_state_initialized);
+ if (!service_process_state_initialized)
+ return -1;
Albert Bodenhamer 2012/01/20 20:34:19 What is the significance of -1 here?
Scott Byer 2012/01/20 23:13:37 Added a comment at the top of the routine; renumbe
TestServiceProcess service_process;
EXPECT_EQ(&service_process, g_service_process);
@@ -204,6 +221,9 @@ int CloudPrintMockService_Main(SetExpectationsCallback set_expectations) {
EXPECT_TRUE(server.Init());
EXPECT_TRUE(state->SignalReady(service_process.IOMessageLoopProxy(),
base::Bind(&ShutdownTask)));
+#if defined(OS_MACOSX)
+ mock_launchd.SignalReady();
+#endif
// Connect up the parent/child IPC channel to signal that the test can
// continue.
@@ -285,6 +305,13 @@ class CloudPrintProxyPolicyStartupTest : public base::MultiProcessTest,
std::string startup_channel_id_;
scoped_ptr<IPC::ChannelProxy> startup_channel_;
+#if defined(OS_MACOSX)
+ ScopedTempDir temp_dir_;
+ FilePath executable_path_, bundle_path_;
+ scoped_ptr<MockLaunchd> mock_launchd_;
+ scoped_ptr<Launchd::ScopedInstance> scoped_launchd_instance_;
+#endif
+
private:
class WindowedChannelConnectionObserver {
public:
@@ -313,7 +340,6 @@ class CloudPrintProxyPolicyStartupTest : public base::MultiProcessTest,
WindowedChannelConnectionObserver observer_;
};
-
CloudPrintProxyPolicyStartupTest::CloudPrintProxyPolicyStartupTest()
: ui_thread_(content::BrowserThread::UI, &message_loop_),
io_thread_("CloudPrintProxyPolicyTestThread") {
@@ -325,6 +351,18 @@ CloudPrintProxyPolicyStartupTest::~CloudPrintProxyPolicyStartupTest() {
void CloudPrintProxyPolicyStartupTest::SetUp() {
base::Thread::Options options(MessageLoop::TYPE_IO, 0);
ASSERT_TRUE(io_thread_.StartWithOptions(options));
+
+#if defined(OS_MACOSX)
+ EXPECT_TRUE(temp_dir_.CreateUniqueTempDir());
+ EXPECT_TRUE(MockLaunchd::MakeABundle(temp_dir_.path(),
+ "CloudPrintProxyTest",
+ &bundle_path_,
+ &executable_path_));
+ mock_launchd_.reset(new MockLaunchd(executable_path_, &message_loop_,
+ true, false));
+ scoped_launchd_instance_.reset(
+ new Launchd::ScopedInstance(mock_launchd_.get()));
+#endif
}
base::ProcessHandle CloudPrintProxyPolicyStartupTest::Launch(
@@ -387,6 +425,9 @@ CommandLine CloudPrintProxyPolicyStartupTest::MakeCmdLine(
bool debug_on_start) {
CommandLine cl = MultiProcessTest::MakeCmdLine(procname, debug_on_start);
cl.AppendSwitchASCII(switches::kProcessChannelID, startup_channel_id_);
+#if defined(OS_MACOSX)
+ cl.AppendSwitchASCII(kTestExecutablePath, executable_path_.value());
+#endif
return cl;
}
« no previous file with comments | « no previous file | chrome/chrome_tests.gypi » ('j') | chrome/common/mac/mock_launchd.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698