chrome/browser/sessions/session_types_unittest.cc
// Ensure all transition types and qualifiers are converted to/from the sync
// TabNavigation representation properly.
Ensure all transition types and qualifiers are converted to/from the sync
TabNavigation representation properly.
Ensure all transition types and qualifiers are converted to / from the sync TabNavigation representation properly .
TEST(TabNavigationTest, TransitionTypes) {
  scoped_ptr<content::NavigationEntry> navigation_entry(
      MakeNavigationEntryForTest());
  for (uint32 core_type = content::PAGE_TRANSITION_LINK;
       core_type != content::PAGE_TRANSITION_LAST_CORE; ++core_type) {
    for (uint32 qualifier = content::PAGE_TRANSITION_FORWARD_BACK;
         qualifier != 0; qualifier <<= 1) {
      if (qualifier == 0x08000000)
        continue;  
      content::PageTransition transition =
          static_cast<content::PageTransition>(core_type | qualifier);
      navigation_entry->SetTransitionType(transition);
      const TabNavigation& navigation =
          TabNavigation::FromNavigationEntry(kIndex, *navigation_entry);
      const sync_pb::TabNavigation& sync_data = navigation.ToSyncData();
      const TabNavigation& constructed_nav =
          TabNavigation::FromSyncData(kIndex, sync_data);
      const content::PageTransition constructed_transition =
          SessionTypesTestHelper::GetTransitionType(constructed_nav);
      EXPECT_EQ(transition, constructed_transition);
    }
  }
}
TEST ( TabNavigationTest , TransitionTypes ) { scoped_ptr < content :: NavigationEntry > navigation_entry ( MakeNavigationEntryForTest ( ) ) ; for ( uint32 core_type = content :: PAGE_TRANSITION_LINK ; core_type != content :: PAGE_TRANSITION_LAST_CORE ; ++ core_type ) { for ( uint32 qualifier = content :: PAGE_TRANSITION_FORWARD_BACK ; qualifier != 0 ; qualifier <<= 1 ) { if ( qualifier == 0x08000000 ) continue ; content :: PageTransition transition = static_cast < content :: PageTransition > ( core_type | qualifier ) ; navigation_entry -> SetTransitionType ( transition ) ; const TabNavigation & navigation = TabNavigation :: FromNavigationEntry ( kIndex , * navigation_entry ) ; const sync_pb :: TabNavigation & sync_data = navigation . ToSyncData ( ) ; const TabNavigation & constructed_nav = TabNavigation :: FromSyncData ( kIndex , sync_data ) ; const content :: PageTransition constructed_transition = SessionTypesTestHelper :: GetTransitionType ( constructed_nav ) ; EXPECT_EQ ( transition , constructed_transition ) ; } } }
Ensure all transition types and qualifiers are converted to/from the sync
TabNavigation representation properly.
Ensure all transition types and qualifiers are converted to / from the sync TabNavigation representation properly .
// Because qualifier is a uint32, left shifting will eventually overflow // and hit zero again. SERVER_REDIRECT, as the last qualifier and also // in place of the sign bit, is therefore the last transition before // breaking. // 0x08000000 is not a valid qualifier.