1// Copyright 2014 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#include <string> 6 7#include "base/command_line.h" 8#include "chrome/browser/apps/app_browsertest_util.h" 9#include "chrome/browser/ui/app_list/app_list_service.h" 10#include "extensions/common/extension.h" 11#include "extensions/common/switches.h" 12#include "ui/app_list/app_list_switches.h" 13 14namespace { 15 16// The path of the test application within the "platform_apps" directory. 17const char kCustomLauncherPagePath[] = "custom_launcher_page"; 18 19// The app ID of the test application. 20const char kCustomLauncherPageID[] = "lmadimbbgapmngbiclpjjngmdickadpl"; 21 22} // namespace 23 24// Browser tests for custom launcher pages, platform apps that run as a page in 25// the app launcher. Within this test class, LoadAndLaunchPlatformApp runs the 26// app inside the launcher, not as a standalone background page. 27// the app launcher. 28class CustomLauncherPageBrowserTest 29 : public extensions::PlatformAppBrowserTest { 30 public: 31 CustomLauncherPageBrowserTest() {} 32 33 virtual void SetUpCommandLine(base::CommandLine* command_line) OVERRIDE { 34 PlatformAppBrowserTest::SetUpCommandLine(command_line); 35 36 // Custom launcher pages only work in the experimental app list. 37 command_line->AppendSwitch(app_list::switches::kEnableExperimentalAppList); 38 39 // The test app must be whitelisted to use launcher_page. 40 command_line->AppendSwitchASCII( 41 extensions::switches::kWhitelistedExtensionID, kCustomLauncherPageID); 42 } 43 44 // Open the launcher. Ignores the Extension argument (this will simply 45 // activate any loaded launcher pages). 46 virtual void LaunchPlatformApp( 47 const extensions::Extension* /*unused*/) OVERRIDE { 48 AppListService* service = 49 AppListService::Get(chrome::HOST_DESKTOP_TYPE_NATIVE); 50 DCHECK(service); 51 service->ShowForProfile(browser()->profile()); 52 } 53 54 private: 55 DISALLOW_COPY_AND_ASSIGN(CustomLauncherPageBrowserTest); 56}; 57 58IN_PROC_BROWSER_TEST_F(CustomLauncherPageBrowserTest, LoadPageAndOpenLauncher) { 59 LoadAndLaunchPlatformApp(kCustomLauncherPagePath, "Launched"); 60} 61