| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "apps/shell_window.h" | 5 #include "apps/app_window.h" |
| 6 #include "apps/shell_window_registry.h" | 6 #include "apps/app_window_registry.h" |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "chrome/browser/apps/app_browsertest_util.h" | 8 #include "chrome/browser/apps/app_browsertest_util.h" |
| 9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
| 10 #include "chrome/browser/extensions/api/feedback_private/feedback_private_api.h" | 10 #include "chrome/browser/extensions/api/feedback_private/feedback_private_api.h" |
| 11 #include "chrome/browser/extensions/component_loader.h" | 11 #include "chrome/browser/extensions/component_loader.h" |
| 12 #include "chrome/browser/extensions/extension_browsertest.h" | 12 #include "chrome/browser/extensions/extension_browsertest.h" |
| 13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/browser/ui/browser.h" | 14 #include "chrome/browser/ui/browser.h" |
| 15 #include "chrome/common/extensions/api/feedback_private.h" | 15 #include "chrome/common/extensions/api/feedback_private.h" |
| 16 #include "chrome/test/base/in_process_browser_test.h" | 16 #include "chrome/test/base/in_process_browser_test.h" |
| 17 #include "chrome/test/base/ui_test_utils.h" | 17 #include "chrome/test/base/ui_test_utils.h" |
| 18 #include "content/public/common/content_switches.h" | 18 #include "content/public/common/content_switches.h" |
| 19 #include "extensions/browser/event_router.h" | 19 #include "extensions/browser/event_router.h" |
| 20 #include "extensions/browser/extension_system.h" | 20 #include "extensions/browser/extension_system.h" |
| 21 | 21 |
| 22 using apps::ShellWindow; | 22 using apps::AppWindow; |
| 23 using apps::ShellWindowRegistry; | 23 using apps::AppWindowRegistry; |
| 24 using extensions::Extension; | 24 using extensions::Extension; |
| 25 | 25 |
| 26 namespace { | 26 namespace { |
| 27 | 27 |
| 28 void StopMessageLoopCallback() { | 28 void StopMessageLoopCallback() { |
| 29 base::MessageLoopForUI::current()->Quit(); | 29 base::MessageLoopForUI::current()->Quit(); |
| 30 } | 30 } |
| 31 | 31 |
| 32 } // namespace | 32 } // namespace |
| 33 | 33 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 55 | 55 |
| 56 void StartFeedbackUI() { | 56 void StartFeedbackUI() { |
| 57 base::Closure callback = base::Bind(&StopMessageLoopCallback); | 57 base::Closure callback = base::Bind(&StopMessageLoopCallback); |
| 58 extensions::FeedbackPrivateGetStringsFunction::set_test_callback(&callback); | 58 extensions::FeedbackPrivateGetStringsFunction::set_test_callback(&callback); |
| 59 InvokeFeedbackUI(); | 59 InvokeFeedbackUI(); |
| 60 content::RunMessageLoop(); | 60 content::RunMessageLoop(); |
| 61 extensions::FeedbackPrivateGetStringsFunction::set_test_callback(NULL); | 61 extensions::FeedbackPrivateGetStringsFunction::set_test_callback(NULL); |
| 62 } | 62 } |
| 63 | 63 |
| 64 void VerifyFeedbackAppLaunch() { | 64 void VerifyFeedbackAppLaunch() { |
| 65 ShellWindow* window = | 65 AppWindow* window = |
| 66 PlatformAppBrowserTest::GetFirstShellWindowForBrowser(browser()); | 66 PlatformAppBrowserTest::GetFirstAppWindowForBrowser(browser()); |
| 67 ASSERT_TRUE(window); | 67 ASSERT_TRUE(window); |
| 68 const Extension* feedback_app = window->extension(); | 68 const Extension* feedback_app = window->extension(); |
| 69 ASSERT_TRUE(feedback_app); | 69 ASSERT_TRUE(feedback_app); |
| 70 EXPECT_EQ(feedback_app->id(), std::string(kFeedbackExtensionId)); | 70 EXPECT_EQ(feedback_app->id(), std::string(kFeedbackExtensionId)); |
| 71 } | 71 } |
| 72 | 72 |
| 73 private: | 73 private: |
| 74 void InvokeFeedbackUI() { | 74 void InvokeFeedbackUI() { |
| 75 extensions::FeedbackPrivateAPI* api = | 75 extensions::FeedbackPrivateAPI* api = |
| 76 extensions::FeedbackPrivateAPI::GetFactoryInstance()->GetForProfile( | 76 extensions::FeedbackPrivateAPI::GetFactoryInstance()->GetForProfile( |
| 77 browser()->profile()); | 77 browser()->profile()); |
| 78 api->RequestFeedback("Test description", | 78 api->RequestFeedback("Test description", |
| 79 "Test tag", | 79 "Test tag", |
| 80 GURL("http://www.test.com")); | 80 GURL("http://www.test.com")); |
| 81 } | 81 } |
| 82 }; | 82 }; |
| 83 | 83 |
| 84 IN_PROC_BROWSER_TEST_F(FeedbackTest, ShowFeedback) { | 84 IN_PROC_BROWSER_TEST_F(FeedbackTest, ShowFeedback) { |
| 85 WaitForExtensionViewsToLoad(); | 85 WaitForExtensionViewsToLoad(); |
| 86 | 86 |
| 87 ASSERT_TRUE(IsFeedbackAppAvailable()); | 87 ASSERT_TRUE(IsFeedbackAppAvailable()); |
| 88 StartFeedbackUI(); | 88 StartFeedbackUI(); |
| 89 VerifyFeedbackAppLaunch(); | 89 VerifyFeedbackAppLaunch(); |
| 90 } | 90 } |
| 91 | 91 |
| 92 } // namespace extensions | 92 } // namespace extensions |
| OLD | NEW |