OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "build/build_config.h" | 5 #include "build/build_config.h" |
6 | 6 |
7 #if defined(TOOLKIT_GTK) | 7 #if defined(TOOLKIT_GTK) |
8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
9 #endif | 9 #endif |
10 | 10 |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, IncognitoDragging) { | 309 IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, IncognitoDragging) { |
310 ExtensionService* service = browser()->profile()->GetExtensionService(); | 310 ExtensionService* service = browser()->profile()->GetExtensionService(); |
311 | 311 |
312 // The tooltips for each respective browser action. | 312 // The tooltips for each respective browser action. |
313 const char kTooltipA[] = "Make this page red"; | 313 const char kTooltipA[] = "Make this page red"; |
314 const char kTooltipB[] = "grow"; | 314 const char kTooltipB[] = "grow"; |
315 const char kTooltipC[] = "Test setPopup()"; | 315 const char kTooltipC[] = "Test setPopup()"; |
316 | 316 |
317 const size_t size_before = service->extensions()->size(); | 317 const size_t size_before = service->extensions()->size(); |
318 | 318 |
319 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII( | 319 const Extension* extension_a = LoadExtension(test_data_dir_.AppendASCII( |
320 "browser_action/basics"))); | 320 "browser_action/basics")); |
321 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII( | 321 const Extension* extension_b = LoadExtension(test_data_dir_.AppendASCII( |
322 "browser_action/popup"))); | 322 "browser_action/popup")); |
323 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII( | 323 const Extension* extension_c = LoadExtension(test_data_dir_.AppendASCII( |
324 "browser_action/add_popup"))); | 324 "browser_action/add_popup")); |
| 325 ASSERT_TRUE(extension_a); |
| 326 ASSERT_TRUE(extension_b); |
| 327 ASSERT_TRUE(extension_c); |
325 | 328 |
326 // Test that there are 3 browser actions in the toolbar. | 329 // Test that there are 3 browser actions in the toolbar. |
327 ASSERT_EQ(size_before + 3, service->extensions()->size()); | 330 ASSERT_EQ(size_before + 3, service->extensions()->size()); |
328 ASSERT_EQ(3, GetBrowserActionsBar().NumberOfBrowserActions()); | 331 ASSERT_EQ(3, GetBrowserActionsBar().NumberOfBrowserActions()); |
329 | 332 |
330 // Now enable 2 of the extensions in incognito mode, and test that the browser | 333 // Now enable 2 of the extensions in incognito mode, and test that the browser |
331 // actions show up. | 334 // actions show up. |
332 service->extension_prefs()->SetIsIncognitoEnabled( | 335 service->extension_prefs()->SetIsIncognitoEnabled(extension_a->id(), true); |
333 service->extensions()->at(size_before)->id(), true); | 336 service->extension_prefs()->SetIsIncognitoEnabled(extension_c->id(), true); |
334 service->extension_prefs()->SetIsIncognitoEnabled( | |
335 service->extensions()->at(size_before + 2)->id(), true); | |
336 | 337 |
337 Profile* incognito_profile = browser()->profile()->GetOffTheRecordProfile(); | 338 Profile* incognito_profile = browser()->profile()->GetOffTheRecordProfile(); |
338 Browser* incognito_browser = Browser::Create(incognito_profile); | 339 Browser* incognito_browser = Browser::Create(incognito_profile); |
339 BrowserActionTestUtil incognito_bar(incognito_browser); | 340 BrowserActionTestUtil incognito_bar(incognito_browser); |
340 | 341 |
341 // Navigate just to have a tab in this window, otherwise wonky things happen. | 342 // Navigate just to have a tab in this window, otherwise wonky things happen. |
342 ui_test_utils::OpenURLOffTheRecord(browser()->profile(), GURL("about:blank")); | 343 ui_test_utils::OpenURLOffTheRecord(browser()->profile(), GURL("about:blank")); |
343 | 344 |
344 ASSERT_EQ(2, incognito_bar.NumberOfBrowserActions()); | 345 ASSERT_EQ(2, incognito_bar.NumberOfBrowserActions()); |
345 | 346 |
346 // Ensure that the browser actions are in the right order (ABC). | 347 // Ensure that the browser actions are in the right order (ABC). |
347 EXPECT_EQ(kTooltipA, GetBrowserActionsBar().GetTooltip(0)); | 348 EXPECT_EQ(kTooltipA, GetBrowserActionsBar().GetTooltip(0)); |
348 EXPECT_EQ(kTooltipB, GetBrowserActionsBar().GetTooltip(1)); | 349 EXPECT_EQ(kTooltipB, GetBrowserActionsBar().GetTooltip(1)); |
349 EXPECT_EQ(kTooltipC, GetBrowserActionsBar().GetTooltip(2)); | 350 EXPECT_EQ(kTooltipC, GetBrowserActionsBar().GetTooltip(2)); |
350 | 351 |
351 EXPECT_EQ(kTooltipA, incognito_bar.GetTooltip(0)); | 352 EXPECT_EQ(kTooltipA, incognito_bar.GetTooltip(0)); |
352 EXPECT_EQ(kTooltipC, incognito_bar.GetTooltip(1)); | 353 EXPECT_EQ(kTooltipC, incognito_bar.GetTooltip(1)); |
353 | 354 |
354 // Now rearrange them and ensure that they are rearranged correctly in both | 355 // Now rearrange them and ensure that they are rearranged correctly in both |
355 // regular and incognito mode. | 356 // regular and incognito mode. |
356 | 357 |
357 // ABC -> CAB | 358 // ABC -> CAB |
358 service->toolbar_model()->MoveBrowserAction( | 359 service->toolbar_model()->MoveBrowserAction(extension_c, 0); |
359 service->extensions()->at(size_before + 2), 0); | |
360 | 360 |
361 EXPECT_EQ(kTooltipC, GetBrowserActionsBar().GetTooltip(0)); | 361 EXPECT_EQ(kTooltipC, GetBrowserActionsBar().GetTooltip(0)); |
362 EXPECT_EQ(kTooltipA, GetBrowserActionsBar().GetTooltip(1)); | 362 EXPECT_EQ(kTooltipA, GetBrowserActionsBar().GetTooltip(1)); |
363 EXPECT_EQ(kTooltipB, GetBrowserActionsBar().GetTooltip(2)); | 363 EXPECT_EQ(kTooltipB, GetBrowserActionsBar().GetTooltip(2)); |
364 | 364 |
365 EXPECT_EQ(kTooltipC, incognito_bar.GetTooltip(0)); | 365 EXPECT_EQ(kTooltipC, incognito_bar.GetTooltip(0)); |
366 EXPECT_EQ(kTooltipA, incognito_bar.GetTooltip(1)); | 366 EXPECT_EQ(kTooltipA, incognito_bar.GetTooltip(1)); |
367 | 367 |
368 // CAB -> CBA | 368 // CAB -> CBA |
369 service->toolbar_model()->MoveBrowserAction( | 369 service->toolbar_model()->MoveBrowserAction(extension_b, 1); |
370 service->extensions()->at(size_before + 1), 1); | |
371 | 370 |
372 EXPECT_EQ(kTooltipC, GetBrowserActionsBar().GetTooltip(0)); | 371 EXPECT_EQ(kTooltipC, GetBrowserActionsBar().GetTooltip(0)); |
373 EXPECT_EQ(kTooltipB, GetBrowserActionsBar().GetTooltip(1)); | 372 EXPECT_EQ(kTooltipB, GetBrowserActionsBar().GetTooltip(1)); |
374 EXPECT_EQ(kTooltipA, GetBrowserActionsBar().GetTooltip(2)); | 373 EXPECT_EQ(kTooltipA, GetBrowserActionsBar().GetTooltip(2)); |
375 | 374 |
376 EXPECT_EQ(kTooltipC, incognito_bar.GetTooltip(0)); | 375 EXPECT_EQ(kTooltipC, incognito_bar.GetTooltip(0)); |
377 EXPECT_EQ(kTooltipA, incognito_bar.GetTooltip(1)); | 376 EXPECT_EQ(kTooltipA, incognito_bar.GetTooltip(1)); |
378 } | 377 } |
379 | 378 |
380 // Disabled because of failures (crashes) on ASAN bot. | 379 // Disabled because of failures (crashes) on ASAN bot. |
(...skipping 19 matching lines...) Expand all Loading... |
400 BrowserActionExecuted( | 399 BrowserActionExecuted( |
401 browser()->profile(), action->extension_id(), browser()); | 400 browser()->profile(), action->extension_id(), browser()); |
402 | 401 |
403 // It can take a moment for the background page to actually get destroyed | 402 // It can take a moment for the background page to actually get destroyed |
404 // so we wait for the notification before checking that it's really gone | 403 // so we wait for the notification before checking that it's really gone |
405 // and the badge text has been set. | 404 // and the badge text has been set. |
406 host_destroyed_observer.Wait(); | 405 host_destroyed_observer.Wait(); |
407 ASSERT_FALSE(manager->GetBackgroundHostForExtension(extension->id())); | 406 ASSERT_FALSE(manager->GetBackgroundHostForExtension(extension->id())); |
408 ASSERT_EQ("X", action->GetBadgeText(ExtensionAction::kDefaultTabId)); | 407 ASSERT_EQ("X", action->GetBadgeText(ExtensionAction::kDefaultTabId)); |
409 } | 408 } |
OLD | NEW |