Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2011 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 "base/command_line.h" | |
| 6 #include "chrome/browser/extensions/extension_browsertest.h" | |
| 7 #include "chrome/browser/extensions/extension_service.h" | |
| 8 #include "chrome/browser/profiles/profile.h" | |
| 9 #include "chrome/browser/ui/browser.h" | |
| 10 #include "chrome/browser/ui/browser_list.h" | |
| 11 #include "chrome/common/chrome_switches.h" | |
| 12 #include "chrome/common/extensions/extension_constants.h" | |
| 13 #include "chrome/test/base/ui_test_utils.h" | |
| 14 #include "testing/gtest/include/gtest/gtest.h" | |
| 15 | |
| 16 class PlaformAppBrowserTest : public ExtensionBrowserTest { | |
| 17 public: | |
| 18 virtual void SetUpCommandLine(CommandLine* command_line) { | |
| 19 ExtensionBrowserTest::SetUpCommandLine(command_line); | |
| 20 command_line->AppendSwitch(switches::kEnablePlatformApps); | |
| 21 } | |
| 22 | |
| 23 void LoadAndLaunchPlatformApp(const char* name) { | |
| 24 EXPECT_TRUE(LoadExtension(test_data_dir_.AppendASCII(name))); | |
| 25 | |
| 26 ExtensionService* service = browser()->profile()->GetExtensionService(); | |
| 27 const Extension* extension = service->GetExtensionById( | |
| 28 last_loaded_extension_id_, false); | |
| 29 EXPECT_TRUE(extension); | |
| 30 | |
| 31 size_t browser_count = BrowserList::size(); | |
| 32 | |
| 33 Browser::OpenApplication( | |
| 34 browser()->profile(), | |
| 35 extension, | |
| 36 extension_misc::LAUNCH_SHELL, | |
| 37 GURL(), | |
| 38 NEW_WINDOW); | |
| 39 | |
| 40 // Now we have a new browser instance. | |
| 41 EXPECT_EQ(browser_count + 1, BrowserList::size()); | |
| 42 } | |
| 43 }; | |
| 44 | |
| 45 IN_PROC_BROWSER_TEST_F(PlaformAppBrowserTest, OpenAppInShellContainer) { | |
| 46 // Start with one browser, new platform app will create another. | |
| 47 ASSERT_EQ(1u, BrowserList::size()); | |
| 48 | |
| 49 LoadAndLaunchPlatformApp("platform_app"); | |
|
miket_OOO
2011/11/30 19:29:13
Unless you have a philosophical reason to hardcode
Mihai Parparita -not on Chrome
2011/11/30 22:38:47
As discussed, this is a reference to the platform_
| |
| 50 | |
| 51 // The launch should have created a new browser, so there should be 2 now. | |
| 52 ASSERT_EQ(2u, BrowserList::size()); | |
| 53 | |
| 54 // The new browser is the last one. | |
| 55 BrowserList::const_reverse_iterator reverse_iterator(BrowserList::end()); | |
| 56 Browser* new_browser = *(reverse_iterator++); | |
| 57 | |
| 58 ASSERT_TRUE(new_browser); | |
| 59 ASSERT_TRUE(new_browser != browser()); | |
| 60 | |
| 61 // Expect an app in a shell window. | |
| 62 EXPECT_TRUE(new_browser->is_app()); | |
| 63 EXPECT_TRUE(new_browser->is_type_shell()); | |
| 64 } | |
| OLD | NEW |