OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/variations/variations_seed_store.h" | 5 #include "components/variations/variations_seed_store.h" |
6 | 6 |
7 #include "base/base64.h" | 7 #include "base/base64.h" |
8 #include "base/prefs/testing_pref_service.h" | 8 #include "base/prefs/testing_pref_service.h" |
9 #include "components/compression/compression_utils.h" | 9 #include "components/compression/compression_utils.h" |
10 #include "components/variations/pref_names.h" | 10 #include "components/variations/pref_names.h" |
11 #include "components/variations/proto/study.pb.h" | 11 #include "components/variations/proto/study.pb.h" |
12 #include "components/variations/proto/variations_seed.pb.h" | 12 #include "components/variations/proto/variations_seed.pb.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
14 | 14 |
15 #if defined(OS_ANDROID) | |
16 #include "components/variations/android/variations_seed_bridge.h" | |
17 #include "components/variations/android/variations_seed_bridge_test.h" | |
18 #endif // OS_ANDROID | |
19 | |
15 namespace variations { | 20 namespace variations { |
16 | 21 |
17 namespace { | 22 namespace { |
18 | 23 |
19 class TestVariationsSeedStore : public VariationsSeedStore { | 24 class TestVariationsSeedStore : public VariationsSeedStore { |
20 public: | 25 public: |
21 explicit TestVariationsSeedStore(PrefService* local_state) | 26 explicit TestVariationsSeedStore(PrefService* local_state) |
22 : VariationsSeedStore(local_state) {} | 27 : VariationsSeedStore(local_state) {} |
23 ~TestVariationsSeedStore() override {} | 28 ~TestVariationsSeedStore() override {} |
24 | 29 |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
371 EXPECT_TRUE(base::Base64Decode(base64_before_seed_data, &before_seed_data)); | 376 EXPECT_TRUE(base::Base64Decode(base64_before_seed_data, &before_seed_data)); |
372 EXPECT_TRUE(base::Base64Decode(base64_after_seed_data, &after_seed_data)); | 377 EXPECT_TRUE(base::Base64Decode(base64_after_seed_data, &after_seed_data)); |
373 EXPECT_TRUE(base::Base64Decode(base64_delta_data, &delta_data)); | 378 EXPECT_TRUE(base::Base64Decode(base64_delta_data, &delta_data)); |
374 | 379 |
375 std::string output; | 380 std::string output; |
376 EXPECT_TRUE(VariationsSeedStore::ApplyDeltaPatch(before_seed_data, delta_data, | 381 EXPECT_TRUE(VariationsSeedStore::ApplyDeltaPatch(before_seed_data, delta_data, |
377 &output)); | 382 &output)); |
378 EXPECT_EQ(after_seed_data, output); | 383 EXPECT_EQ(after_seed_data, output); |
379 } | 384 } |
380 | 385 |
386 #if defined(OS_ANDROID) | |
387 TEST(VariationsSeedStoreTest, ImportFirstRunJavaSeed) { | |
388 android::SetTestData(); | |
389 std::string seed_data; | |
390 std::string seed_signature; | |
391 std::string seed_country; | |
392 std::string response_date; | |
393 bool is_gzip_compressed; | |
394 android::GetVariationsFirstRunSeed(&seed_data, &seed_signature, &seed_country, | |
395 &response_date, &is_gzip_compressed); | |
396 EXPECT_EQ(seed_data, "raw_seed_data_test"); | |
Alexei Svitkine (slow)
2015/11/20 16:28:28
Nit: Expected value should be on the left
Alexander Agulenko
2015/11/20 17:33:31
Done.
| |
397 EXPECT_EQ(seed_signature, "seed_signature_test"); | |
398 EXPECT_EQ(seed_country, "seed_country_code_test"); | |
399 EXPECT_EQ(response_date, "seed_response_date_test"); | |
400 EXPECT_EQ(is_gzip_compressed, true); | |
401 android::ClearJavaFirstRunPrefs(); | |
402 android::GetVariationsFirstRunSeed(&seed_data, &seed_signature, &seed_country, | |
403 &response_date, &is_gzip_compressed); | |
404 EXPECT_EQ(seed_data, ""); | |
405 EXPECT_EQ(seed_signature, ""); | |
406 EXPECT_EQ(seed_country, ""); | |
407 // TODO(agulenko): uncomment lines below after landing CL with fixing bug | |
408 // about missing date and gzip_compressed pref clearance. | |
409 /* EXPECT_EQ(response_date, ""); | |
410 EXPECT_EQ(is_gzip_compressed, false); */ | |
411 } | |
412 #endif // OS_ANDROID | |
413 | |
381 } // namespace variations | 414 } // namespace variations |
OLD | NEW |