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 const Extension* extension_a = LoadExtension(test_data_dir_.AppendASCII( | 319 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII( |
320 "browser_action/basics")); | 320 "browser_action/basics"))); |
321 const Extension* extension_b = LoadExtension(test_data_dir_.AppendASCII( | 321 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII( |
322 "browser_action/popup")); | 322 "browser_action/popup"))); |
323 const Extension* extension_c = LoadExtension(test_data_dir_.AppendASCII( | 323 ASSERT_TRUE(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); | |
328 | 325 |
329 // Test that there are 3 browser actions in the toolbar. | 326 // Test that there are 3 browser actions in the toolbar. |
330 ASSERT_EQ(size_before + 3, service->extensions()->size()); | 327 ASSERT_EQ(size_before + 3, service->extensions()->size()); |
331 ASSERT_EQ(3, GetBrowserActionsBar().NumberOfBrowserActions()); | 328 ASSERT_EQ(3, GetBrowserActionsBar().NumberOfBrowserActions()); |
332 | 329 |
333 // Now enable 2 of the extensions in incognito mode, and test that the browser | 330 // Now enable 2 of the extensions in incognito mode, and test that the browser |
334 // actions show up. | 331 // actions show up. |
335 service->extension_prefs()->SetIsIncognitoEnabled(extension_a->id(), true); | 332 service->extension_prefs()->SetIsIncognitoEnabled( |
336 service->extension_prefs()->SetIsIncognitoEnabled(extension_c->id(), true); | 333 service->extensions()->at(size_before)->id(), true); |
| 334 service->extension_prefs()->SetIsIncognitoEnabled( |
| 335 service->extensions()->at(size_before + 2)->id(), true); |
337 | 336 |
338 Profile* incognito_profile = browser()->profile()->GetOffTheRecordProfile(); | 337 Profile* incognito_profile = browser()->profile()->GetOffTheRecordProfile(); |
339 Browser* incognito_browser = Browser::Create(incognito_profile); | 338 Browser* incognito_browser = Browser::Create(incognito_profile); |
340 BrowserActionTestUtil incognito_bar(incognito_browser); | 339 BrowserActionTestUtil incognito_bar(incognito_browser); |
341 | 340 |
342 // Navigate just to have a tab in this window, otherwise wonky things happen. | 341 // Navigate just to have a tab in this window, otherwise wonky things happen. |
343 ui_test_utils::OpenURLOffTheRecord(browser()->profile(), GURL("about:blank")); | 342 ui_test_utils::OpenURLOffTheRecord(browser()->profile(), GURL("about:blank")); |
344 | 343 |
345 ASSERT_EQ(2, incognito_bar.NumberOfBrowserActions()); | 344 ASSERT_EQ(2, incognito_bar.NumberOfBrowserActions()); |
346 | 345 |
347 // Ensure that the browser actions are in the right order (ABC). | 346 // Ensure that the browser actions are in the right order (ABC). |
348 EXPECT_EQ(kTooltipA, GetBrowserActionsBar().GetTooltip(0)); | 347 EXPECT_EQ(kTooltipA, GetBrowserActionsBar().GetTooltip(0)); |
349 EXPECT_EQ(kTooltipB, GetBrowserActionsBar().GetTooltip(1)); | 348 EXPECT_EQ(kTooltipB, GetBrowserActionsBar().GetTooltip(1)); |
350 EXPECT_EQ(kTooltipC, GetBrowserActionsBar().GetTooltip(2)); | 349 EXPECT_EQ(kTooltipC, GetBrowserActionsBar().GetTooltip(2)); |
351 | 350 |
352 EXPECT_EQ(kTooltipA, incognito_bar.GetTooltip(0)); | 351 EXPECT_EQ(kTooltipA, incognito_bar.GetTooltip(0)); |
353 EXPECT_EQ(kTooltipC, incognito_bar.GetTooltip(1)); | 352 EXPECT_EQ(kTooltipC, incognito_bar.GetTooltip(1)); |
354 | 353 |
355 // Now rearrange them and ensure that they are rearranged correctly in both | 354 // Now rearrange them and ensure that they are rearranged correctly in both |
356 // regular and incognito mode. | 355 // regular and incognito mode. |
357 | 356 |
358 // ABC -> CAB | 357 // ABC -> CAB |
359 service->toolbar_model()->MoveBrowserAction(extension_c, 0); | 358 service->toolbar_model()->MoveBrowserAction( |
| 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(extension_b, 1); | 369 service->toolbar_model()->MoveBrowserAction( |
| 370 service->extensions()->at(size_before + 1), 1); |
370 | 371 |
371 EXPECT_EQ(kTooltipC, GetBrowserActionsBar().GetTooltip(0)); | 372 EXPECT_EQ(kTooltipC, GetBrowserActionsBar().GetTooltip(0)); |
372 EXPECT_EQ(kTooltipB, GetBrowserActionsBar().GetTooltip(1)); | 373 EXPECT_EQ(kTooltipB, GetBrowserActionsBar().GetTooltip(1)); |
373 EXPECT_EQ(kTooltipA, GetBrowserActionsBar().GetTooltip(2)); | 374 EXPECT_EQ(kTooltipA, GetBrowserActionsBar().GetTooltip(2)); |
374 | 375 |
375 EXPECT_EQ(kTooltipC, incognito_bar.GetTooltip(0)); | 376 EXPECT_EQ(kTooltipC, incognito_bar.GetTooltip(0)); |
376 EXPECT_EQ(kTooltipA, incognito_bar.GetTooltip(1)); | 377 EXPECT_EQ(kTooltipA, incognito_bar.GetTooltip(1)); |
377 } | 378 } |
378 | 379 |
379 // Disabled because of failures (crashes) on ASAN bot. | 380 // Disabled because of failures (crashes) on ASAN bot. |
(...skipping 19 matching lines...) Expand all Loading... |
399 BrowserActionExecuted( | 400 BrowserActionExecuted( |
400 browser()->profile(), action->extension_id(), browser()); | 401 browser()->profile(), action->extension_id(), browser()); |
401 | 402 |
402 // It can take a moment for the background page to actually get destroyed | 403 // It can take a moment for the background page to actually get destroyed |
403 // so we wait for the notification before checking that it's really gone | 404 // so we wait for the notification before checking that it's really gone |
404 // and the badge text has been set. | 405 // and the badge text has been set. |
405 host_destroyed_observer.Wait(); | 406 host_destroyed_observer.Wait(); |
406 ASSERT_FALSE(manager->GetBackgroundHostForExtension(extension->id())); | 407 ASSERT_FALSE(manager->GetBackgroundHostForExtension(extension->id())); |
407 ASSERT_EQ("X", action->GetBadgeText(ExtensionAction::kDefaultTabId)); | 408 ASSERT_EQ("X", action->GetBadgeText(ExtensionAction::kDefaultTabId)); |
408 } | 409 } |
OLD | NEW |