| Index: apps/app_shim/app_shim_host_mac_unittest.cc
|
| diff --git a/apps/app_shim/app_shim_host_mac_unittest.cc b/apps/app_shim/app_shim_host_mac_unittest.cc
|
| index f9a8e4dcc775b8a5c9d9986335ca1db089bd2b1e..746ffaed110e7426207bd6a89b4654efd1311830 100644
|
| --- a/apps/app_shim/app_shim_host_mac_unittest.cc
|
| +++ b/apps/app_shim/app_shim_host_mac_unittest.cc
|
| @@ -28,10 +28,6 @@ class TestingAppShimHost : public AppShimHost {
|
| fails_profile_ = fails_profile;
|
| }
|
|
|
| - void set_fails_launch(bool fails_launch) {
|
| - fails_launch_ = fails_launch;
|
| - }
|
| -
|
| protected:
|
| virtual Profile* FetchProfileForDirectory(const std::string& profile_dir)
|
| OVERRIDE;
|
| @@ -40,7 +36,6 @@ class TestingAppShimHost : public AppShimHost {
|
| private:
|
| Profile* test_profile_;
|
| bool fails_profile_;
|
| - bool fails_launch_;
|
|
|
| ScopedVector<IPC::Message> sent_messages_;
|
|
|
| @@ -49,8 +44,7 @@ class TestingAppShimHost : public AppShimHost {
|
|
|
| TestingAppShimHost::TestingAppShimHost(Profile* profile)
|
| : test_profile_(profile),
|
| - fails_profile_(false),
|
| - fails_launch_(false) {
|
| + fails_profile_(false) {
|
| }
|
|
|
| bool TestingAppShimHost::ReceiveMessage(IPC::Message* message) {
|
| @@ -72,7 +66,11 @@ Profile* TestingAppShimHost::FetchProfileForDirectory(
|
| class AppShimHostTest : public testing::Test,
|
| public apps::AppShimHandler {
|
| public:
|
| - AppShimHostTest() : launch_count_(0), close_count_(0), focus_count_(0) {}
|
| + AppShimHostTest() : fail_launch_(false),
|
| + launch_count_(0),
|
| + launch_now_count_(0),
|
| + close_count_(0),
|
| + focus_count_(0) {}
|
|
|
| TestingAppShimHost* host() { return host_.get(); }
|
| TestingProfile* profile() { return profile_.get(); }
|
| @@ -91,15 +89,19 @@ class AppShimHostTest : public testing::Test,
|
| }
|
|
|
| protected:
|
| - virtual bool OnShimLaunch(Host* host) OVERRIDE {
|
| + virtual bool OnShimLaunch(Host* host, bool launch_now) OVERRIDE {
|
| ++launch_count_;
|
| - return true;
|
| + if (launch_now)
|
| + ++launch_now_count_;
|
| + return !fail_launch_;
|
| }
|
|
|
| virtual void OnShimClose(Host* host) OVERRIDE { ++close_count_; }
|
| virtual void OnShimFocus(Host* host) OVERRIDE { ++focus_count_; }
|
|
|
| + bool fail_launch_;
|
| int launch_count_;
|
| + int launch_now_count_;
|
| int close_count_;
|
| int focus_count_;
|
|
|
| @@ -124,11 +126,12 @@ const char kTestProfileDir[] = "Default";
|
| TEST_F(AppShimHostTest, TestLaunchAppWithHandler) {
|
| apps::AppShimHandler::RegisterHandler(kTestAppId, this);
|
| EXPECT_TRUE(host()->ReceiveMessage(
|
| - new AppShimHostMsg_LaunchApp(kTestProfileDir, kTestAppId)));
|
| + new AppShimHostMsg_LaunchApp(kTestProfileDir, kTestAppId, true)));
|
| EXPECT_EQ(kTestAppId,
|
| implicit_cast<apps::AppShimHandler::Host*>(host())->GetAppId());
|
| EXPECT_TRUE(LaunchWasSuccessful());
|
| EXPECT_EQ(1, launch_count_);
|
| + EXPECT_EQ(1, launch_now_count_);
|
| EXPECT_EQ(0, focus_count_);
|
| EXPECT_EQ(0, close_count_);
|
|
|
| @@ -140,16 +143,32 @@ TEST_F(AppShimHostTest, TestLaunchAppWithHandler) {
|
| apps::AppShimHandler::RemoveHandler(kTestAppId);
|
| }
|
|
|
| +TEST_F(AppShimHostTest, TestNoLaunchNow) {
|
| + apps::AppShimHandler::RegisterHandler(kTestAppId, this);
|
| + EXPECT_TRUE(host()->ReceiveMessage(
|
| + new AppShimHostMsg_LaunchApp(kTestProfileDir, kTestAppId, false)));
|
| + EXPECT_EQ(kTestAppId,
|
| + implicit_cast<apps::AppShimHandler::Host*>(host())->GetAppId());
|
| + EXPECT_TRUE(LaunchWasSuccessful());
|
| + EXPECT_EQ(1, launch_count_);
|
| + EXPECT_EQ(0, launch_now_count_);
|
| + EXPECT_EQ(0, focus_count_);
|
| + EXPECT_EQ(0, close_count_);
|
| + apps::AppShimHandler::RemoveHandler(kTestAppId);
|
| +}
|
| +
|
| TEST_F(AppShimHostTest, TestFailProfile) {
|
| host()->set_fails_profile(true);
|
| host()->ReceiveMessage(
|
| - new AppShimHostMsg_LaunchApp(kTestProfileDir, kTestAppId));
|
| + new AppShimHostMsg_LaunchApp(kTestProfileDir, kTestAppId, true));
|
| ASSERT_FALSE(LaunchWasSuccessful());
|
| }
|
|
|
| TEST_F(AppShimHostTest, TestFailLaunch) {
|
| - host()->set_fails_launch(true);
|
| + apps::AppShimHandler::RegisterHandler(kTestAppId, this);
|
| + fail_launch_ = true;
|
| host()->ReceiveMessage(
|
| - new AppShimHostMsg_LaunchApp(kTestProfileDir, kTestAppId));
|
| + new AppShimHostMsg_LaunchApp(kTestProfileDir, kTestAppId, true));
|
| ASSERT_FALSE(LaunchWasSuccessful());
|
| + apps::AppShimHandler::RemoveHandler(kTestAppId);
|
| }
|
|
|