| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 "base/strings/stringprintf.h" | 5 #include "base/strings/stringprintf.h" |
| 6 #include "chrome/browser/apps/app_browsertest_util.h" | 6 #include "chrome/browser/apps/app_browsertest_util.h" |
| 7 #include "chrome/browser/extensions/extension_test_message_listener.h" | 7 #include "chrome/browser/extensions/extension_test_message_listener.h" |
| 8 #include "chrome/browser/guest_view/guest_view_manager.h" | |
| 9 #include "chrome/browser/guest_view/guest_view_manager_factory.h" | |
| 10 #include "chrome/common/chrome_switches.h" | 8 #include "chrome/common/chrome_switches.h" |
| 11 #include "chrome/test/base/ui_test_utils.h" | 9 #include "chrome/test/base/ui_test_utils.h" |
| 12 #include "content/public/browser/notification_service.h" | 10 #include "content/public/browser/notification_service.h" |
| 13 #include "content/public/browser/render_process_host.h" | 11 #include "content/public/browser/render_process_host.h" |
| 14 #include "content/public/test/browser_test_utils.h" | 12 #include "content/public/test/browser_test_utils.h" |
| 15 #include "content/public/test/test_utils.h" | 13 #include "content/public/test/test_utils.h" |
| 14 #include "extensions/browser/guest_view/guest_view_manager.h" |
| 15 #include "extensions/browser/guest_view/guest_view_manager_factory.h" |
| 16 #include "net/test/embedded_test_server/embedded_test_server.h" | 16 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 17 #include "net/test/embedded_test_server/http_request.h" | 17 #include "net/test/embedded_test_server/http_request.h" |
| 18 #include "net/test/embedded_test_server/http_response.h" | 18 #include "net/test/embedded_test_server/http_response.h" |
| 19 | 19 |
| 20 namespace { | 20 namespace { |
| 21 | 21 |
| 22 class TestGuestViewManager : public GuestViewManager { | 22 class TestGuestViewManager : public extensions::GuestViewManager { |
| 23 public: | 23 public: |
| 24 explicit TestGuestViewManager(content::BrowserContext* context) : | 24 explicit TestGuestViewManager(content::BrowserContext* context) : |
| 25 GuestViewManager(context), | 25 extensions::GuestViewManager(context), |
| 26 web_contents_(NULL) {} | 26 web_contents_(NULL) {} |
| 27 | 27 |
| 28 content::WebContents* WaitForGuestCreated() { | 28 content::WebContents* WaitForGuestCreated() { |
| 29 if (web_contents_) | 29 if (web_contents_) |
| 30 return web_contents_; | 30 return web_contents_; |
| 31 | 31 |
| 32 message_loop_runner_ = new content::MessageLoopRunner; | 32 message_loop_runner_ = new content::MessageLoopRunner; |
| 33 message_loop_runner_->Run(); | 33 message_loop_runner_->Run(); |
| 34 return web_contents_; | 34 return web_contents_; |
| 35 } | 35 } |
| 36 | 36 |
| 37 private: | 37 private: |
| 38 // GuestViewManager override: | 38 // GuestViewManager override: |
| 39 virtual void AddGuest(int guest_instance_id, | 39 virtual void AddGuest(int guest_instance_id, |
| 40 content::WebContents* guest_web_contents) OVERRIDE{ | 40 content::WebContents* guest_web_contents) OVERRIDE{ |
| 41 GuestViewManager::AddGuest(guest_instance_id, guest_web_contents); | 41 extensions::GuestViewManager::AddGuest( |
| 42 guest_instance_id, guest_web_contents); |
| 42 web_contents_ = guest_web_contents; | 43 web_contents_ = guest_web_contents; |
| 43 | 44 |
| 44 if (message_loop_runner_) | 45 if (message_loop_runner_) |
| 45 message_loop_runner_->Quit(); | 46 message_loop_runner_->Quit(); |
| 46 } | 47 } |
| 47 | 48 |
| 48 content::WebContents* web_contents_; | 49 content::WebContents* web_contents_; |
| 49 scoped_refptr<content::MessageLoopRunner> message_loop_runner_; | 50 scoped_refptr<content::MessageLoopRunner> message_loop_runner_; |
| 50 }; | 51 }; |
| 51 | 52 |
| 52 // Test factory for creating test instances of GuestViewManager. | 53 // Test factory for creating test instances of GuestViewManager. |
| 53 class TestGuestViewManagerFactory : public GuestViewManagerFactory { | 54 class TestGuestViewManagerFactory : public extensions::GuestViewManagerFactory { |
| 54 public: | 55 public: |
| 55 TestGuestViewManagerFactory() : | 56 TestGuestViewManagerFactory() : |
| 56 test_guest_view_manager_(NULL) {} | 57 test_guest_view_manager_(NULL) {} |
| 57 | 58 |
| 58 virtual ~TestGuestViewManagerFactory() {} | 59 virtual ~TestGuestViewManagerFactory() {} |
| 59 | 60 |
| 60 virtual GuestViewManager* CreateGuestViewManager( | 61 virtual extensions::GuestViewManager* CreateGuestViewManager( |
| 61 content::BrowserContext* context) OVERRIDE { | 62 content::BrowserContext* context) OVERRIDE { |
| 62 return GetManager(context); | 63 return GetManager(context); |
| 63 } | 64 } |
| 64 | 65 |
| 65 TestGuestViewManager* GetManager(content::BrowserContext* context) { | 66 TestGuestViewManager* GetManager(content::BrowserContext* context) { |
| 66 if (!test_guest_view_manager_) { | 67 if (!test_guest_view_manager_) { |
| 67 test_guest_view_manager_ = new TestGuestViewManager(context); | 68 test_guest_view_manager_ = new TestGuestViewManager(context); |
| 68 } | 69 } |
| 69 return test_guest_view_manager_; | 70 return test_guest_view_manager_; |
| 70 } | 71 } |
| 71 | 72 |
| 72 private: | 73 private: |
| 73 TestGuestViewManager* test_guest_view_manager_; | 74 TestGuestViewManager* test_guest_view_manager_; |
| 74 | 75 |
| 75 DISALLOW_COPY_AND_ASSIGN(TestGuestViewManagerFactory); | 76 DISALLOW_COPY_AND_ASSIGN(TestGuestViewManagerFactory); |
| 76 }; | 77 }; |
| 77 | 78 |
| 78 } // namespace | 79 } // namespace |
| 79 | 80 |
| 80 class AppViewTest : public extensions::PlatformAppBrowserTest { | 81 class AppViewTest : public extensions::PlatformAppBrowserTest { |
| 81 public: | 82 public: |
| 82 AppViewTest() { | 83 AppViewTest() { |
| 83 GuestViewManager::set_factory_for_testing(&factory_); | 84 extensions::GuestViewManager::set_factory_for_testing(&factory_); |
| 84 } | 85 } |
| 85 | 86 |
| 86 TestGuestViewManager* GetGuestViewManager() { | 87 TestGuestViewManager* GetGuestViewManager() { |
| 87 return factory_.GetManager(browser()->profile()); | 88 return factory_.GetManager(browser()->profile()); |
| 88 } | 89 } |
| 89 | 90 |
| 90 enum TestServer { | 91 enum TestServer { |
| 91 NEEDS_TEST_SERVER, | 92 NEEDS_TEST_SERVER, |
| 92 NO_TEST_SERVER | 93 NO_TEST_SERVER |
| 93 }; | 94 }; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 // Tests that <appview> is able to navigate to another installed app. | 142 // Tests that <appview> is able to navigate to another installed app. |
| 142 IN_PROC_BROWSER_TEST_F(AppViewTest, TestAppViewBasic) { | 143 IN_PROC_BROWSER_TEST_F(AppViewTest, TestAppViewBasic) { |
| 143 const extensions::Extension* skeleton_app = | 144 const extensions::Extension* skeleton_app = |
| 144 InstallPlatformApp("app_view/shim/skeleton"); | 145 InstallPlatformApp("app_view/shim/skeleton"); |
| 145 TestHelper("testAppViewBasic", | 146 TestHelper("testAppViewBasic", |
| 146 "app_view/shim", | 147 "app_view/shim", |
| 147 skeleton_app->id(), | 148 skeleton_app->id(), |
| 148 NO_TEST_SERVER); | 149 NO_TEST_SERVER); |
| 149 } | 150 } |
| 150 | 151 |
| OLD | NEW |