| OLD | NEW | 
|    1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |    1 // Copyright (c) 2012 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 "sync/internal_api/public/base/model_type.h" |    5 #include "sync/internal_api/public/base/model_type.h" | 
|    6  |    6  | 
|    7 #include <string> |    7 #include <string> | 
|    8  |    8  | 
|    9 #include "base/memory/scoped_ptr.h" |    9 #include "base/memory/scoped_ptr.h" | 
|   10 #include "base/test/values_test_util.h" |   10 #include "base/test/values_test_util.h" | 
| (...skipping 21 matching lines...) Expand all  Loading... | 
|   32   for (int i = FIRST_REAL_MODEL_TYPE; i < MODEL_TYPE_COUNT; ++i) { |   32   for (int i = FIRST_REAL_MODEL_TYPE; i < MODEL_TYPE_COUNT; ++i) { | 
|   33     ModelType model_type = ModelTypeFromInt(i); |   33     ModelType model_type = ModelTypeFromInt(i); | 
|   34     scoped_ptr<StringValue> value(ModelTypeToValue(model_type)); |   34     scoped_ptr<StringValue> value(ModelTypeToValue(model_type)); | 
|   35     EXPECT_EQ(model_type, ModelTypeFromValue(*value)); |   35     EXPECT_EQ(model_type, ModelTypeFromValue(*value)); | 
|   36   } |   36   } | 
|   37 } |   37 } | 
|   38  |   38  | 
|   39 TEST_F(ModelTypeTest, ModelTypeSetToValue) { |   39 TEST_F(ModelTypeTest, ModelTypeSetToValue) { | 
|   40   const ModelTypeSet model_types(BOOKMARKS, APPS); |   40   const ModelTypeSet model_types(BOOKMARKS, APPS); | 
|   41  |   41  | 
|   42   scoped_ptr<ListValue> value(ModelTypeSetToValue(model_types)); |   42   scoped_ptr<base::ListValue> value(ModelTypeSetToValue(model_types)); | 
|   43   EXPECT_EQ(2u, value->GetSize()); |   43   EXPECT_EQ(2u, value->GetSize()); | 
|   44   std::string types[2]; |   44   std::string types[2]; | 
|   45   EXPECT_TRUE(value->GetString(0, &types[0])); |   45   EXPECT_TRUE(value->GetString(0, &types[0])); | 
|   46   EXPECT_TRUE(value->GetString(1, &types[1])); |   46   EXPECT_TRUE(value->GetString(1, &types[1])); | 
|   47   EXPECT_EQ("Bookmarks", types[0]); |   47   EXPECT_EQ("Bookmarks", types[0]); | 
|   48   EXPECT_EQ("Apps", types[1]); |   48   EXPECT_EQ("Apps", types[1]); | 
|   49 } |   49 } | 
|   50  |   50  | 
|   51 TEST_F(ModelTypeTest, ModelTypeSetFromValue) { |   51 TEST_F(ModelTypeTest, ModelTypeSetFromValue) { | 
|   52   // Try empty set first. |   52   // Try empty set first. | 
|   53   ModelTypeSet model_types; |   53   ModelTypeSet model_types; | 
|   54   scoped_ptr<ListValue> value(ModelTypeSetToValue(model_types)); |   54   scoped_ptr<base::ListValue> value(ModelTypeSetToValue(model_types)); | 
|   55   EXPECT_TRUE(model_types.Equals(ModelTypeSetFromValue(*value))); |   55   EXPECT_TRUE(model_types.Equals(ModelTypeSetFromValue(*value))); | 
|   56  |   56  | 
|   57   // Now try with a few random types. |   57   // Now try with a few random types. | 
|   58   model_types.Put(BOOKMARKS); |   58   model_types.Put(BOOKMARKS); | 
|   59   model_types.Put(APPS); |   59   model_types.Put(APPS); | 
|   60   value.reset(ModelTypeSetToValue(model_types)); |   60   value.reset(ModelTypeSetToValue(model_types)); | 
|   61   EXPECT_TRUE(model_types.Equals(ModelTypeSetFromValue(*value))); |   61   EXPECT_TRUE(model_types.Equals(ModelTypeSetFromValue(*value))); | 
|   62 } |   62 } | 
|   63  |   63  | 
|   64 TEST_F(ModelTypeTest, IsRealDataType) { |   64 TEST_F(ModelTypeTest, IsRealDataType) { | 
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   99     // This is not necessary for the mapping to be valid, but most instances of |   99     // This is not necessary for the mapping to be valid, but most instances of | 
|  100     // UMA_HISTOGRAM that use this mapping specify MODEL_TYPE_COUNT as the |  100     // UMA_HISTOGRAM that use this mapping specify MODEL_TYPE_COUNT as the | 
|  101     // maximum possible value.  If you break this assumption, you should update |  101     // maximum possible value.  If you break this assumption, you should update | 
|  102     // those histograms. |  102     // those histograms. | 
|  103     EXPECT_LT(histogram_value, MODEL_TYPE_COUNT); |  103     EXPECT_LT(histogram_value, MODEL_TYPE_COUNT); | 
|  104   } |  104   } | 
|  105 } |  105 } | 
|  106  |  106  | 
|  107 }  // namespace |  107 }  // namespace | 
|  108 }  // namespace syncer |  108 }  // namespace syncer | 
| OLD | NEW |