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 "chrome/browser/apps/app_browsertest_util.h" | 5 #include "chrome/browser/apps/app_browsertest_util.h" |
6 #include "chrome/browser/extensions/api/management/management_api.h" | 6 #include "chrome/browser/extensions/api/management/management_api.h" |
7 #include "chrome/browser/extensions/extension_apitest.h" | 7 #include "chrome/browser/extensions/extension_apitest.h" |
8 #include "chrome/browser/extensions/extension_function_test_utils.h" | 8 #include "chrome/browser/extensions/extension_function_test_utils.h" |
9 #include "chrome/browser/extensions/test_extension_dir.h" | 9 #include "chrome/browser/extensions/test_extension_dir.h" |
10 #include "chrome/test/base/ui_test_utils.h" | 10 #include "chrome/test/base/ui_test_utils.h" |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 | 90 |
91 const Extension* extension = LoadExtension(dir.unpacked_path()); | 91 const Extension* extension = LoadExtension(dir.unpacked_path()); |
92 ASSERT_TRUE(extension); | 92 ASSERT_TRUE(extension); |
93 const std::string extension_id = extension->id(); | 93 const std::string extension_id = extension->id(); |
94 | 94 |
95 // Somewhat arbitrary upper limit of 30 iterations. If the extension manages | 95 // Somewhat arbitrary upper limit of 30 iterations. If the extension manages |
96 // to reload itself that often without being terminated, the test fails | 96 // to reload itself that often without being terminated, the test fails |
97 // anyway. | 97 // anyway. |
98 for (int i = 0; i < 30; i++) { | 98 for (int i = 0; i < 30; i++) { |
99 content::WindowedNotificationObserver unload_observer( | 99 content::WindowedNotificationObserver unload_observer( |
100 chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, | 100 extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, |
101 content::NotificationService::AllSources()); | 101 content::NotificationService::AllSources()); |
102 content::WindowedNotificationObserver load_observer( | 102 content::WindowedNotificationObserver load_observer( |
103 chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED, | 103 extensions::NOTIFICATION_EXTENSION_LOADED_DEPRECATED, |
104 content::NotificationService::AllSources()); | 104 content::NotificationService::AllSources()); |
105 | 105 |
106 ASSERT_TRUE(ExecuteScriptInBackgroundPageNoWait( | 106 ASSERT_TRUE(ExecuteScriptInBackgroundPageNoWait( |
107 extension_id, "chrome.runtime.reload();")); | 107 extension_id, "chrome.runtime.reload();")); |
108 unload_observer.Wait(); | 108 unload_observer.Wait(); |
109 | 109 |
110 if (registry->GetExtensionById(extension_id, | 110 if (registry->GetExtensionById(extension_id, |
111 ExtensionRegistry::TERMINATED)) { | 111 ExtensionRegistry::TERMINATED)) { |
112 break; | 112 break; |
113 } else { | 113 } else { |
114 load_observer.Wait(); | 114 load_observer.Wait(); |
115 WaitForExtensionViewsToLoad(); | 115 WaitForExtensionViewsToLoad(); |
116 } | 116 } |
117 } | 117 } |
118 ASSERT_TRUE( | 118 ASSERT_TRUE( |
119 registry->GetExtensionById(extension_id, ExtensionRegistry::TERMINATED)); | 119 registry->GetExtensionById(extension_id, ExtensionRegistry::TERMINATED)); |
120 } | 120 } |
121 | 121 |
122 } // namespace extensions | 122 } // namespace extensions |
OLD | NEW |