Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(17)

Side by Side Diff: components/variations/variations_seed_store_unittest.cc

Issue 1462953004: Unit tests for importing prefs from the Java side implemented (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Compile error fix Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/variations/android/variations_seed_bridge.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #endif // OS_ANDROID
18
15 namespace variations { 19 namespace variations {
16 20
17 namespace { 21 namespace {
18 22
19 class TestVariationsSeedStore : public VariationsSeedStore { 23 class TestVariationsSeedStore : public VariationsSeedStore {
20 public: 24 public:
21 explicit TestVariationsSeedStore(PrefService* local_state) 25 explicit TestVariationsSeedStore(PrefService* local_state)
22 : VariationsSeedStore(local_state) {} 26 : VariationsSeedStore(local_state) {}
23 ~TestVariationsSeedStore() override {} 27 ~TestVariationsSeedStore() override {}
24 28
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 EXPECT_TRUE(base::Base64Decode(base64_before_seed_data, &before_seed_data)); 375 EXPECT_TRUE(base::Base64Decode(base64_before_seed_data, &before_seed_data));
372 EXPECT_TRUE(base::Base64Decode(base64_after_seed_data, &after_seed_data)); 376 EXPECT_TRUE(base::Base64Decode(base64_after_seed_data, &after_seed_data));
373 EXPECT_TRUE(base::Base64Decode(base64_delta_data, &delta_data)); 377 EXPECT_TRUE(base::Base64Decode(base64_delta_data, &delta_data));
374 378
375 std::string output; 379 std::string output;
376 EXPECT_TRUE(VariationsSeedStore::ApplyDeltaPatch(before_seed_data, delta_data, 380 EXPECT_TRUE(VariationsSeedStore::ApplyDeltaPatch(before_seed_data, delta_data,
377 &output)); 381 &output));
378 EXPECT_EQ(after_seed_data, output); 382 EXPECT_EQ(after_seed_data, output);
379 } 383 }
380 384
385 #if defined(OS_ANDROID)
386 TEST(VariationsSeedStoreTest, ImportFirstRunJavaSeed) {
387 const std::string test_seed_data = "raw_seed_data_test";
388 const std::string test_seed_signature = "seed_signature_test";
389 const std::string test_seed_country = "seed_country_code_test";
390 const std::string test_response_date = "seed_response_date_test";
391 const bool test_is_gzip_compressed = true;
392 android::SetJavaFirstRunPrefsForTesting(test_seed_data, test_seed_signature,
393 test_seed_country, test_response_date,
394 test_is_gzip_compressed);
395
396 std::string seed_data;
397 std::string seed_signature;
398 std::string seed_country;
399 std::string response_date;
400 bool is_gzip_compressed;
401 android::GetVariationsFirstRunSeed(&seed_data, &seed_signature, &seed_country,
402 &response_date, &is_gzip_compressed);
403 EXPECT_EQ(test_seed_data, seed_data);
404 EXPECT_EQ(test_seed_signature, seed_signature);
405 EXPECT_EQ(test_seed_country, seed_country);
406 EXPECT_EQ(test_response_date, response_date);
407 EXPECT_EQ(test_is_gzip_compressed, is_gzip_compressed);
408
409 android::ClearJavaFirstRunPrefs();
410 android::GetVariationsFirstRunSeed(&seed_data, &seed_signature, &seed_country,
411 &response_date, &is_gzip_compressed);
412 EXPECT_EQ("", seed_data);
413 EXPECT_EQ("", seed_signature);
414 EXPECT_EQ("", seed_country);
415 EXPECT_EQ("", response_date);
416 EXPECT_FALSE(is_gzip_compressed);
417 }
418 #endif // OS_ANDROID
419
381 } // namespace variations 420 } // namespace variations
OLDNEW
« no previous file with comments | « components/variations/android/variations_seed_bridge.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698