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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/file_path.h" | 6 #include "base/file_path.h" |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "chrome/browser/bookmarks/bookmark_model.h" | 8 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 9 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
9 #include "chrome/browser/extensions/browser_action_test_util.h" | 10 #include "chrome/browser/extensions/browser_action_test_util.h" |
10 #include "chrome/browser/extensions/extension_apitest.h" | 11 #include "chrome/browser/extensions/extension_apitest.h" |
11 #include "chrome/browser/extensions/extension_host.h" | 12 #include "chrome/browser/extensions/extension_host.h" |
12 #include "chrome/browser/extensions/extension_test_message_listener.h" | 13 #include "chrome/browser/extensions/extension_test_message_listener.h" |
13 #include "chrome/browser/extensions/extension_service.h" | 14 #include "chrome/browser/extensions/extension_service.h" |
14 #include "chrome/browser/extensions/lazy_background_page_test_util.h" | 15 #include "chrome/browser/extensions/lazy_background_page_test_util.h" |
15 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
16 #include "chrome/browser/ui/browser.h" | 17 #include "chrome/browser/ui/browser.h" |
17 #include "chrome/browser/ui/browser_tabstrip.h" | 18 #include "chrome/browser/ui/browser_tabstrip.h" |
18 #include "chrome/browser/ui/browser_window.h" | 19 #include "chrome/browser/ui/browser_window.h" |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 EXPECT_FALSE(listener_incognito.was_satisfied()); | 299 EXPECT_FALSE(listener_incognito.was_satisfied()); |
299 } | 300 } |
300 | 301 |
301 // Trigger a bookmark created event and ensure both pages receive it. | 302 // Trigger a bookmark created event and ensure both pages receive it. |
302 { | 303 { |
303 ExtensionTestMessageListener listener("waiting", false); | 304 ExtensionTestMessageListener listener("waiting", false); |
304 ExtensionTestMessageListener listener_incognito("waiting_incognito", false); | 305 ExtensionTestMessageListener listener_incognito("waiting_incognito", false); |
305 | 306 |
306 LazyBackgroundObserver page_complete(browser()->profile()), | 307 LazyBackgroundObserver page_complete(browser()->profile()), |
307 page2_complete(incognito_browser->profile()); | 308 page2_complete(incognito_browser->profile()); |
308 BookmarkModel* bookmark_model = browser()->profile()->GetBookmarkModel(); | 309 BookmarkModel* bookmark_model = |
| 310 BookmarkModelFactory::GetForProfile(browser()->profile()); |
309 ui_test_utils::WaitForBookmarkModelToLoad(bookmark_model); | 311 ui_test_utils::WaitForBookmarkModelToLoad(bookmark_model); |
310 const BookmarkNode* parent = bookmark_model->bookmark_bar_node(); | 312 const BookmarkNode* parent = bookmark_model->bookmark_bar_node(); |
311 bookmark_model->AddURL( | 313 bookmark_model->AddURL( |
312 parent, 0, ASCIIToUTF16("Title"), GURL("about:blank")); | 314 parent, 0, ASCIIToUTF16("Title"), GURL("about:blank")); |
313 page_complete.Wait(); | 315 page_complete.Wait(); |
314 page2_complete.Wait(); | 316 page2_complete.Wait(); |
315 | 317 |
316 // Both pages received the message. | 318 // Both pages received the message. |
317 EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id_)); | 319 EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id_)); |
318 EXPECT_FALSE(pmi->GetBackgroundHostForExtension(last_loaded_extension_id_)); | 320 EXPECT_FALSE(pmi->GetBackgroundHostForExtension(last_loaded_extension_id_)); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id_)); | 367 EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id_)); |
366 | 368 |
367 // The browser action has a new title. | 369 // The browser action has a new title. |
368 BrowserActionTestUtil browser_action(browser()); | 370 BrowserActionTestUtil browser_action(browser()); |
369 ASSERT_EQ(1, browser_action.NumberOfBrowserActions()); | 371 ASSERT_EQ(1, browser_action.NumberOfBrowserActions()); |
370 EXPECT_EQ("Success", browser_action.GetTooltip(0)); | 372 EXPECT_EQ("Success", browser_action.GetTooltip(0)); |
371 } | 373 } |
372 | 374 |
373 // TODO: background page with timer. | 375 // TODO: background page with timer. |
374 // TODO: background page that interacts with popup. | 376 // TODO: background page that interacts with popup. |
OLD | NEW |