Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 5 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
| 11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/path_service.h" | 13 #include "base/path_service.h" |
| 14 #include "base/stl_util.h" | 14 #include "base/stl_util.h" |
| 15 #include "base/string_split.h" | 15 #include "base/string_split.h" |
| 16 #include "base/string_util.h" | 16 #include "base/string_util.h" |
| 17 #include "base/strings/string_number_conversions.h" | 17 #include "base/strings/string_number_conversions.h" |
| 18 #include "base/utf_string_conversions.h" | 18 #include "base/utf_string_conversions.h" |
| 19 #include "chrome/browser/defaults.h" | 19 #include "chrome/browser/defaults.h" |
| 20 #include "chrome/browser/extensions/tab_helper.h" | 20 #include "chrome/browser/extensions/tab_helper.h" |
| 21 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
| 22 #include "chrome/browser/ui/browser.h" | 22 #include "chrome/browser/ui/browser.h" |
| 23 #include "chrome/browser/ui/browser_tabstrip.h" | 23 #include "chrome/browser/ui/browser_tabstrip.h" |
| 24 #include "chrome/browser/ui/tabs/tab_strip_model_delegate.h" | 24 #include "chrome/browser/ui/tabs/tab_strip_model_delegate.h" |
| 25 #include "chrome/browser/ui/tabs/tab_strip_model_order_controller.h" | 25 #include "chrome/browser/ui/tabs/tab_strip_model_order_controller.h" |
| 26 #include "chrome/browser/ui/tabs/test_tab_strip_model_delegate.h" | 26 #include "chrome/browser/ui/tabs/test_tab_strip_model_delegate.h" |
| 27 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" | 27 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" |
| 28 #include "chrome/common/chrome_notification_types.h" | 28 #include "chrome/common/chrome_notification_types.h" |
| 29 #include "chrome/common/extensions/app_launch_manifest_handler.h" | |
| 29 #include "chrome/common/extensions/extension.h" | 30 #include "chrome/common/extensions/extension.h" |
| 30 #include "chrome/common/url_constants.h" | 31 #include "chrome/common/url_constants.h" |
| 31 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 32 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
| 32 #include "chrome/test/base/testing_profile.h" | 33 #include "chrome/test/base/testing_profile.h" |
| 33 #include "content/public/browser/navigation_controller.h" | 34 #include "content/public/browser/navigation_controller.h" |
| 34 #include "content/public/browser/navigation_entry.h" | 35 #include "content/public/browser/navigation_entry.h" |
| 35 #include "content/public/browser/notification_details.h" | 36 #include "content/public/browser/notification_details.h" |
| 36 #include "content/public/browser/notification_registrar.h" | 37 #include "content/public/browser/notification_registrar.h" |
| 37 #include "content/public/browser/notification_source.h" | 38 #include "content/public/browser/notification_source.h" |
| 38 #include "content/public/browser/render_process_host.h" | 39 #include "content/public/browser/render_process_host.h" |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 105 int id_; | 106 int id_; |
| 106 }; | 107 }; |
| 107 | 108 |
| 108 } // namespace | 109 } // namespace |
| 109 | 110 |
| 110 class TabStripModelTest : public ChromeRenderViewHostTestHarness { | 111 class TabStripModelTest : public ChromeRenderViewHostTestHarness { |
| 111 public: | 112 public: |
| 112 TabStripModelTest() : browser_thread_(BrowserThread::UI, &message_loop_) { | 113 TabStripModelTest() : browser_thread_(BrowserThread::UI, &message_loop_) { |
| 113 } | 114 } |
| 114 | 115 |
| 116 virtual void SetUp() OVERRIDE { | |
| 117 ChromeRenderViewHostTestHarness::SetUp(); | |
| 118 std::vector<std::string> app_launch_keys( | |
| 119 extensions::AppLaunchManifestHandler::keys()); | |
| 120 linked_ptr<extensions::AppLaunchManifestHandler> app_launch_handler( | |
| 121 new extensions::AppLaunchManifestHandler); | |
| 122 for (size_t i = 0; i < app_launch_keys.size(); ++i) { | |
| 123 extensions::ManifestHandler::Register(app_launch_keys[i], | |
| 124 app_launch_handler); | |
| 125 } | |
| 126 } | |
|
Yoyo Zhou
2013/02/27 02:43:33
Please also add a TearDown() to call
ManifestHandl
Joe Thomas
2013/03/01 23:26:57
Done.
| |
| 127 | |
| 115 WebContents* CreateWebContents() { | 128 WebContents* CreateWebContents() { |
| 116 return WebContents::Create(WebContents::CreateParams(profile())); | 129 return WebContents::Create(WebContents::CreateParams(profile())); |
| 117 } | 130 } |
| 118 | 131 |
| 119 WebContents* CreateWebContentsWithSharedRPH(WebContents* web_contents) { | 132 WebContents* CreateWebContentsWithSharedRPH(WebContents* web_contents) { |
| 120 WebContents::CreateParams create_params( | 133 WebContents::CreateParams create_params( |
| 121 profile(), web_contents->GetRenderViewHost()->GetSiteInstance()); | 134 profile(), web_contents->GetRenderViewHost()->GetSiteInstance()); |
| 122 WebContents* retval = WebContents::Create(create_params); | 135 WebContents* retval = WebContents::Create(create_params); |
| 123 EXPECT_EQ(retval->GetRenderProcessHost(), | 136 EXPECT_EQ(retval->GetRenderProcessHost(), |
| 124 web_contents->GetRenderProcessHost()); | 137 web_contents->GetRenderProcessHost()); |
| (...skipping 1583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1708 | 1721 |
| 1709 #if defined(OS_WIN) | 1722 #if defined(OS_WIN) |
| 1710 base::FilePath path(FILE_PATH_LITERAL("c:\\foo")); | 1723 base::FilePath path(FILE_PATH_LITERAL("c:\\foo")); |
| 1711 #elif defined(OS_POSIX) | 1724 #elif defined(OS_POSIX) |
| 1712 base::FilePath path(FILE_PATH_LITERAL("/foo")); | 1725 base::FilePath path(FILE_PATH_LITERAL("/foo")); |
| 1713 #endif | 1726 #endif |
| 1714 | 1727 |
| 1715 DictionaryValue manifest; | 1728 DictionaryValue manifest; |
| 1716 manifest.SetString("name", "hi!"); | 1729 manifest.SetString("name", "hi!"); |
| 1717 manifest.SetString("version", "1"); | 1730 manifest.SetString("version", "1"); |
| 1731 manifest.SetString("app.launch.web_url", "http://www.google.com"); | |
| 1718 std::string error; | 1732 std::string error; |
| 1719 scoped_refptr<Extension> extension_app( | 1733 scoped_refptr<Extension> extension_app( |
| 1720 Extension::Create(path, extensions::Manifest::INVALID_LOCATION, | 1734 Extension::Create(path, extensions::Manifest::INVALID_LOCATION, |
| 1721 manifest, Extension::NO_FLAGS, &error)); | 1735 manifest, Extension::NO_FLAGS, &error)); |
| 1722 extension_app->launch_web_url_ = "http://www.google.com"; | 1736 |
| 1723 WebContents* contents1 = CreateWebContents(); | 1737 WebContents* contents1 = CreateWebContents(); |
| 1724 extensions::TabHelper::CreateForWebContents(contents1); | 1738 extensions::TabHelper::CreateForWebContents(contents1); |
| 1725 extensions::TabHelper::FromWebContents(contents1)-> | 1739 extensions::TabHelper::FromWebContents(contents1)-> |
| 1726 SetExtensionApp(extension_app); | 1740 SetExtensionApp(extension_app); |
| 1727 WebContents* contents2 = CreateWebContents(); | 1741 WebContents* contents2 = CreateWebContents(); |
| 1728 extensions::TabHelper::CreateForWebContents(contents2); | 1742 extensions::TabHelper::CreateForWebContents(contents2); |
| 1729 extensions::TabHelper::FromWebContents(contents2)-> | 1743 extensions::TabHelper::FromWebContents(contents2)-> |
| 1730 SetExtensionApp(extension_app); | 1744 SetExtensionApp(extension_app); |
| 1731 WebContents* contents3 = CreateWebContents(); | 1745 WebContents* contents3 = CreateWebContents(); |
| 1732 | 1746 |
| (...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2333 strip.ActivateTabAt(1, true); | 2347 strip.ActivateTabAt(1, true); |
| 2334 ASSERT_EQ(1, observer.GetStateCount()); | 2348 ASSERT_EQ(1, observer.GetStateCount()); |
| 2335 State s(contents2, 1, MockTabStripModelObserver::SELECT); | 2349 State s(contents2, 1, MockTabStripModelObserver::SELECT); |
| 2336 s.src_contents = contents2; | 2350 s.src_contents = contents2; |
| 2337 s.src_index = 1; | 2351 s.src_index = 1; |
| 2338 s.user_gesture = false; | 2352 s.user_gesture = false; |
| 2339 EXPECT_TRUE(observer.StateEquals(0, s)); | 2353 EXPECT_TRUE(observer.StateEquals(0, s)); |
| 2340 strip.RemoveObserver(&observer); | 2354 strip.RemoveObserver(&observer); |
| 2341 strip.CloseAllTabs(); | 2355 strip.CloseAllTabs(); |
| 2342 } | 2356 } |
| OLD | NEW |