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.
5 #include "base/files/file_path.h"
6 #include "chrome/browser/apps/app_browsertest_util.h"
7 #include "chrome/browser/extensions/component_loader.h"
8 #include "chrome/browser/extensions/extension_service.h"
9 #include "chrome/browser/ui/tabs/tab_strip_model.h"
10 #include "chrome/test/base/ui_test_utils.h"
11 #include "components/version_info/version_info.h"
12 #include "content/public/test/browser_test_utils.h"
13 #include "extensions/browser/extension_registry.h"
14 #include "extensions/test/extension_test_message_listener.h"
15 #include "grit/browser_resources.h"
17 using extensions::Extension
;
18 using extensions::ExtensionRegistry
;
21 const char kWallpaperManagerExtensionID
[] = "obklkkbkpaoaejdabbfldmcfplpdgolj";
24 class WallpaperManagerBrowserTest
: public extensions::PlatformAppBrowserTest
{
26 WallpaperManagerBrowserTest();
27 ~WallpaperManagerBrowserTest() override
;
30 void VerifyWallpaperManagerLoaded();
33 void LoadAndLaunchWallpaperManager();
36 WallpaperManagerBrowserTest::WallpaperManagerBrowserTest() {
39 WallpaperManagerBrowserTest::~WallpaperManagerBrowserTest() {
42 void WallpaperManagerBrowserTest::LoadAndLaunchWallpaperManager() {
43 extension_service()->component_loader()->Add(
44 IDR_WALLPAPERMANAGER_MANIFEST
,
45 base::FilePath(FILE_PATH_LITERAL("chromeos/wallpaper_manager")));
46 const Extension
* wallpaper_app
=
47 ExtensionRegistry::Get(profile())->GetExtensionById(
48 kWallpaperManagerExtensionID
, ExtensionRegistry::EVERYTHING
);
49 LaunchPlatformApp(wallpaper_app
);
52 void WallpaperManagerBrowserTest::VerifyWallpaperManagerLoaded() {
53 ExtensionTestMessageListener
window_created_listener(
54 "wallpaper-window-created", false);
55 ExtensionTestMessageListener
launched_listener("launched", false);
56 LoadAndLaunchWallpaperManager();
57 EXPECT_TRUE(window_created_listener
.WaitUntilSatisfied())
58 << "Wallpaper picker window was not created.";
59 EXPECT_TRUE(launched_listener
.WaitUntilSatisfied())
60 << "Wallpaper picker was not loaded.";
63 // Test for crbug.com/410550.
64 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest
, DevLaunchApp
) {
65 VerifyWallpaperManagerLoaded();
68 // Test for crbug.com/410550. Wallpaper picker should be able to create
69 // alpha enabled window successfully.
70 IN_PROC_BROWSER_TEST_F(WallpaperManagerBrowserTest
, StableLaunchApp
) {
71 extensions::ScopedCurrentChannel
channel(version_info::Channel::STABLE
);
72 VerifyWallpaperManagerLoaded();
75 class WallpaperManagerJsTest
: public InProcessBrowserTest
{
77 void RunTest(const base::FilePath
& file
) {
78 GURL url
= ui_test_utils::GetTestUrl(
80 FILE_PATH_LITERAL("chromeos/wallpaper_manager/unit_tests")),
82 ui_test_utils::NavigateToURL(browser(), url
);
84 content::WebContents
* web_contents
=
85 browser()->tab_strip_model()->GetActiveWebContents();
86 ASSERT_TRUE(web_contents
);
88 const std::vector
<int> empty_libraries
;
89 EXPECT_TRUE(ExecuteWebUIResourceTest(web_contents
, empty_libraries
));
93 IN_PROC_BROWSER_TEST_F(WallpaperManagerJsTest
, EventPageTest
) {
94 RunTest(base::FilePath(FILE_PATH_LITERAL("event_page_unittest.html")));