chrome/browser/ui/views/toolbar/browser_actions_container_browsertest.cc
IN_PROC_BROWSER_TEST_F(BrowserActionsContainerTest,
                       MoveBrowserActions) {
  // Load three extensions with browser actions.
  const extensions::Extension* extension_a =
      LoadExtension(test_data_dir_.AppendASCII("api_test")
                                  .AppendASCII("browser_action")
                                  .AppendASCII("basics"));
  ASSERT_TRUE(extension_a);
  const extensions::Extension* extension_b =
      LoadExtension(test_data_dir_.AppendASCII("api_test")
                                  .AppendASCII("browser_action")
                                  .AppendASCII("add_popup"));
  ASSERT_TRUE(extension_b);
  const extensions::Extension* extension_c =
      LoadExtension(test_data_dir_.AppendASCII("api_test")
                                  .AppendASCII("browser_action")
                                  .AppendASCII("remove_popup"));
  ASSERT_TRUE(extension_c);

  EXPECT_EQ(3, browser_actions_bar()->VisibleBrowserActions());
  EXPECT_EQ(3, browser_actions_bar()->NumberOfBrowserActions());

  extensions::ExtensionToolbarModel* model =
      extensions::ExtensionToolbarModel::Get(profile());
  ASSERT_TRUE(model);

  // Order is now A B C.
  EXPECT_EQ(extension_a->id(), browser_actions_bar()->GetExtensionId(0));
  EXPECT_EQ(extension_b->id(), browser_actions_bar()->GetExtensionId(1));
  EXPECT_EQ(extension_c->id(), browser_actions_bar()->GetExtensionId(2));

  // Move C to first position. Order is C A B.
  model->MoveExtensionIcon(extension_c, 0);
  EXPECT_EQ(extension_c->id(), browser_actions_bar()->GetExtensionId(0));
  EXPECT_EQ(extension_a->id(), browser_actions_bar()->GetExtensionId(1));
  EXPECT_EQ(extension_b->id(), browser_actions_bar()->GetExtensionId(2));

  // Move B to third position. Order is still C A B.
  model->MoveExtensionIcon(extension_b, 2);
  EXPECT_EQ(extension_c->id(), browser_actions_bar()->GetExtensionId(0));
  EXPECT_EQ(extension_a->id(), browser_actions_bar()->GetExtensionId(1));
  EXPECT_EQ(extension_b->id(), browser_actions_bar()->GetExtensionId(2));

  // Move B to middle position. Order is C B A.
  model->MoveExtensionIcon(extension_b, 1);
  EXPECT_EQ(extension_c->id(), browser_actions_bar()->GetExtensionId(0));
  EXPECT_EQ(extension_b->id(), browser_actions_bar()->GetExtensionId(1));
  EXPECT_EQ(extension_a->id(), browser_actions_bar()->GetExtensionId(2));
}
// Test moving various browser actions. This is not to check the logic of the
// move (that's in the toolbar model tests), but just to check our ui.
Test moving various browser actions. This is not to check the logic of the
move (that's in the toolbar model tests), but just to check our ui.
Test moving various browser actions . This is not to check the logic of the move ( that ' s in the toolbar model tests ) but just to check our ui .
IN_PROC_BROWSER_TEST_F(BrowserActionsContainerTest,
                       MoveBrowserActions) {
  const extensions::Extension* extension_a =
      LoadExtension(test_data_dir_.AppendASCII("api_test")
                                  .AppendASCII("browser_action")
                                  .AppendASCII("basics"));
  ASSERT_TRUE(extension_a);
  const extensions::Extension* extension_b =
      LoadExtension(test_data_dir_.AppendASCII("api_test")
                                  .AppendASCII("browser_action")
                                  .AppendASCII("add_popup"));
  ASSERT_TRUE(extension_b);
  const extensions::Extension* extension_c =
      LoadExtension(test_data_dir_.AppendASCII("api_test")
                                  .AppendASCII("browser_action")
                                  .AppendASCII("remove_popup"));
  ASSERT_TRUE(extension_c);
  EXPECT_EQ(3, browser_actions_bar()->VisibleBrowserActions());
  EXPECT_EQ(3, browser_actions_bar()->NumberOfBrowserActions());
  extensions::ExtensionToolbarModel* model =
      extensions::ExtensionToolbarModel::Get(profile());
  ASSERT_TRUE(model);
  EXPECT_EQ(extension_a->id(), browser_actions_bar()->GetExtensionId(0));
  EXPECT_EQ(extension_b->id(), browser_actions_bar()->GetExtensionId(1));
  EXPECT_EQ(extension_c->id(), browser_actions_bar()->GetExtensionId(2));
  model->MoveExtensionIcon(extension_c, 0);
  EXPECT_EQ(extension_c->id(), browser_actions_bar()->GetExtensionId(0));
  EXPECT_EQ(extension_a->id(), browser_actions_bar()->GetExtensionId(1));
  EXPECT_EQ(extension_b->id(), browser_actions_bar()->GetExtensionId(2));
  model->MoveExtensionIcon(extension_b, 2);
  EXPECT_EQ(extension_c->id(), browser_actions_bar()->GetExtensionId(0));
  EXPECT_EQ(extension_a->id(), browser_actions_bar()->GetExtensionId(1));
  EXPECT_EQ(extension_b->id(), browser_actions_bar()->GetExtensionId(2));
  model->MoveExtensionIcon(extension_b, 1);
  EXPECT_EQ(extension_c->id(), browser_actions_bar()->GetExtensionId(0));
  EXPECT_EQ(extension_b->id(), browser_actions_bar()->GetExtensionId(1));
  EXPECT_EQ(extension_a->id(), browser_actions_bar()->GetExtensionId(2));
}
IN_PROC_BROWSER_TEST_F ( BrowserActionsContainerTest , MoveBrowserActions ) { const extensions :: Extension * extension_a = LoadExtension ( test_data_dir_ . AppendASCII ( " " ) . AppendASCII ( " " ) . AppendASCII ( " " ) ) ; ASSERT_TRUE ( extension_a ) ; const extensions :: Extension * extension_b = LoadExtension ( test_data_dir_ . AppendASCII ( " " ) . AppendASCII ( " " ) . AppendASCII ( " " ) ) ; ASSERT_TRUE ( extension_b ) ; const extensions :: Extension * extension_c = LoadExtension ( test_data_dir_ . AppendASCII ( " " ) . AppendASCII ( " " ) . AppendASCII ( " " ) ) ; ASSERT_TRUE ( extension_c ) ; EXPECT_EQ ( 3 , browser_actions_bar ( ) -> VisibleBrowserActions ( ) ) ; EXPECT_EQ ( 3 , browser_actions_bar ( ) -> NumberOfBrowserActions ( ) ) ; extensions :: ExtensionToolbarModel * model = extensions :: ExtensionToolbarModel :: Get ( profile ( ) ) ; ASSERT_TRUE ( model ) ; EXPECT_EQ ( extension_a -> id ( ) , browser_actions_bar ( ) -> GetExtensionId ( 0 ) ) ; EXPECT_EQ ( extension_b -> id ( ) , browser_actions_bar ( ) -> GetExtensionId ( 1 ) ) ; EXPECT_EQ ( extension_c -> id ( ) , browser_actions_bar ( ) -> GetExtensionId ( 2 ) ) ; model -> MoveExtensionIcon ( extension_c , 0 ) ; EXPECT_EQ ( extension_c -> id ( ) , browser_actions_bar ( ) -> GetExtensionId ( 0 ) ) ; EXPECT_EQ ( extension_a -> id ( ) , browser_actions_bar ( ) -> GetExtensionId ( 1 ) ) ; EXPECT_EQ ( extension_b -> id ( ) , browser_actions_bar ( ) -> GetExtensionId ( 2 ) ) ; model -> MoveExtensionIcon ( extension_b , 2 ) ; EXPECT_EQ ( extension_c -> id ( ) , browser_actions_bar ( ) -> GetExtensionId ( 0 ) ) ; EXPECT_EQ ( extension_a -> id ( ) , browser_actions_bar ( ) -> GetExtensionId ( 1 ) ) ; EXPECT_EQ ( extension_b -> id ( ) , browser_actions_bar ( ) -> GetExtensionId ( 2 ) ) ; model -> MoveExtensionIcon ( extension_b , 1 ) ; EXPECT_EQ ( extension_c -> id ( ) , browser_actions_bar ( ) -> GetExtensionId ( 0 ) ) ; EXPECT_EQ ( extension_b -> id ( ) , browser_actions_bar ( ) -> GetExtensionId ( 1 ) ) ; EXPECT_EQ ( extension_a -> id ( ) , browser_actions_bar ( ) -> GetExtensionId ( 2 ) ) ; }
Test moving various browser actions.
Test moving various browser actions .
// Load three extensions with browser actions. // Order is now A B C. // Move C to first position. Order is C A B. // Move B to third position. Order is still C A B. // Move B to middle position. Order is C B A.