| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "components/sessions/core/serialized_navigation_entry.h" | 5 #include "components/sessions/core/serialized_navigation_entry.h" |
| 6 | 6 |
| 7 #include <stdint.h> |
| 8 |
| 7 #include <cstddef> | 9 #include <cstddef> |
| 8 #include <string> | 10 #include <string> |
| 9 | 11 |
| 10 #include "base/basictypes.h" | |
| 11 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/pickle.h" | 13 #include "base/pickle.h" |
| 13 #include "base/strings/string16.h" | 14 #include "base/strings/string16.h" |
| 14 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
| 15 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
| 16 #include "base/time/time.h" | 17 #include "base/time/time.h" |
| 17 #include "components/sessions/core/serialized_navigation_driver.h" | 18 #include "components/sessions/core/serialized_navigation_driver.h" |
| 18 #include "components/sessions/core/serialized_navigation_entry_test_helper.h" | 19 #include "components/sessions/core/serialized_navigation_entry_test_helper.h" |
| 19 #include "sync/protocol/session_specifics.pb.h" | 20 #include "sync/protocol/session_specifics.pb.h" |
| 20 #include "sync/util/time.h" | 21 #include "sync/util/time.h" |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 EXPECT_EQ(test_data::kRedirectURL1.spec(), | 188 EXPECT_EQ(test_data::kRedirectURL1.spec(), |
| 188 sync_data.navigation_redirect(1).url()); | 189 sync_data.navigation_redirect(1).url()); |
| 189 } | 190 } |
| 190 | 191 |
| 191 // Ensure all transition types and qualifiers are converted to/from the sync | 192 // Ensure all transition types and qualifiers are converted to/from the sync |
| 192 // SerializedNavigationEntry representation properly. | 193 // SerializedNavigationEntry representation properly. |
| 193 TEST(SerializedNavigationEntryTest, TransitionTypes) { | 194 TEST(SerializedNavigationEntryTest, TransitionTypes) { |
| 194 SerializedNavigationEntry navigation = | 195 SerializedNavigationEntry navigation = |
| 195 SerializedNavigationEntryTestHelper::CreateNavigationForTest(); | 196 SerializedNavigationEntryTestHelper::CreateNavigationForTest(); |
| 196 | 197 |
| 197 for (uint32 core_type = ui::PAGE_TRANSITION_LINK; | 198 for (uint32_t core_type = ui::PAGE_TRANSITION_LINK; |
| 198 core_type != ui::PAGE_TRANSITION_LAST_CORE; ++core_type) { | 199 core_type != ui::PAGE_TRANSITION_LAST_CORE; ++core_type) { |
| 199 // Because qualifier is a uint32, left shifting will eventually overflow | 200 // Because qualifier is a uint32_t, left shifting will eventually overflow |
| 200 // and hit zero again. SERVER_REDIRECT, as the last qualifier and also | 201 // and hit zero again. SERVER_REDIRECT, as the last qualifier and also |
| 201 // in place of the sign bit, is therefore the last transition before | 202 // in place of the sign bit, is therefore the last transition before |
| 202 // breaking. | 203 // breaking. |
| 203 for (uint32 qualifier = ui::PAGE_TRANSITION_FORWARD_BACK; | 204 for (uint32_t qualifier = ui::PAGE_TRANSITION_FORWARD_BACK; qualifier != 0; |
| 204 qualifier != 0; qualifier <<= 1) { | 205 qualifier <<= 1) { |
| 205 if (qualifier == 0x08000000) | 206 if (qualifier == 0x08000000) |
| 206 continue; // 0x08000000 is not a valid qualifier. | 207 continue; // 0x08000000 is not a valid qualifier. |
| 207 ui::PageTransition transition = | 208 ui::PageTransition transition = |
| 208 ui::PageTransitionFromInt(core_type | qualifier); | 209 ui::PageTransitionFromInt(core_type | qualifier); |
| 209 SerializedNavigationEntryTestHelper::SetTransitionType( | 210 SerializedNavigationEntryTestHelper::SetTransitionType( |
| 210 transition, &navigation); | 211 transition, &navigation); |
| 211 | 212 |
| 212 const sync_pb::TabNavigation& sync_data = navigation.ToSyncData(); | 213 const sync_pb::TabNavigation& sync_data = navigation.ToSyncData(); |
| 213 const SerializedNavigationEntry& constructed_nav = | 214 const SerializedNavigationEntry& constructed_nav = |
| 214 SerializedNavigationEntry::FromSyncData(test_data::kIndex, sync_data); | 215 SerializedNavigationEntry::FromSyncData(test_data::kIndex, sync_data); |
| 215 const ui::PageTransition constructed_transition = | 216 const ui::PageTransition constructed_transition = |
| 216 constructed_nav.transition_type(); | 217 constructed_nav.transition_type(); |
| 217 | 218 |
| 218 EXPECT_EQ(transition, constructed_transition); | 219 EXPECT_EQ(transition, constructed_transition); |
| 219 } | 220 } |
| 220 } | 221 } |
| 221 } | 222 } |
| 222 | 223 |
| 223 } // namespace | 224 } // namespace |
| 224 } // namespace sessions | 225 } // namespace sessions |
| OLD | NEW |