custom_launcher_page_browsertest_views.cc revision 5f1c94371a64b3196d4be9466099bb892df9b88e
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 "chrome/common/chrome_switches.h" 11#include "extensions/common/extension.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 and URL of the test application. 20const char kCustomLauncherPageUrl[] = 21 "chrome-extension://lmadimbbgapmngbiclpjjngmdickadpl/main.html"; 22 23} // namespace 24 25// Browser tests for custom launcher pages, platform apps that run as a page in 26// the app launcher. Within this test class, LoadAndLaunchPlatformApp runs the 27// app inside the launcher, not as a standalone background page. 28// the app launcher. 29class CustomLauncherPageBrowserTest 30 : public extensions::PlatformAppBrowserTest { 31 public: 32 CustomLauncherPageBrowserTest() {} 33 34 virtual void SetUpCommandLine(base::CommandLine* command_line) OVERRIDE { 35 PlatformAppBrowserTest::SetUpCommandLine(command_line); 36 37 // Custom launcher pages only work in the experimental app list. 38 command_line->AppendSwitch(app_list::switches::kEnableExperimentalAppList); 39 command_line->AppendSwitchASCII(switches::kCustomLauncherPage, 40 kCustomLauncherPageUrl); 41 } 42 43 // Open the launcher. Ignores the Extension argument (this will simply 44 // activate any loaded launcher pages). 45 virtual void LaunchPlatformApp( 46 const extensions::Extension* /*unused*/) OVERRIDE { 47 AppListService* service = 48 AppListService::Get(chrome::HOST_DESKTOP_TYPE_NATIVE); 49 DCHECK(service); 50 service->ShowForProfile(browser()->profile()); 51 } 52 53 private: 54 DISALLOW_COPY_AND_ASSIGN(CustomLauncherPageBrowserTest); 55}; 56 57IN_PROC_BROWSER_TEST_F(CustomLauncherPageBrowserTest, LoadPageAndOpenLauncher) { 58 LoadAndLaunchPlatformApp(kCustomLauncherPagePath, "Launched"); 59} 60