| 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 "components/sync/engine_impl/js_sync_encryption_handler_observer.h" | 5 #include "components/sync/engine_impl/js_sync_encryption_handler_observer.h" |
| 6 | 6 |
| 7 #include "base/location.h" | 7 #include "base/location.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "base/test/scoped_task_environment.h" |
| 9 #include "base/values.h" | 10 #include "base/values.h" |
| 10 #include "components/sync/base/cryptographer.h" | 11 #include "components/sync/base/cryptographer.h" |
| 11 #include "components/sync/base/fake_encryptor.h" | 12 #include "components/sync/base/fake_encryptor.h" |
| 12 #include "components/sync/base/model_type.h" | 13 #include "components/sync/base/model_type.h" |
| 13 #include "components/sync/base/passphrase_type.h" | 14 #include "components/sync/base/passphrase_type.h" |
| 14 #include "components/sync/base/time.h" | 15 #include "components/sync/base/time.h" |
| 15 #include "components/sync/engine/sync_string_conversions.h" | 16 #include "components/sync/engine/sync_string_conversions.h" |
| 16 #include "components/sync/js/js_event_details.h" | 17 #include "components/sync/js/js_event_details.h" |
| 17 #include "components/sync/js/js_test_util.h" | 18 #include "components/sync/js/js_test_util.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
| 19 | 20 |
| 20 namespace syncer { | 21 namespace syncer { |
| 21 namespace { | 22 namespace { |
| 22 | 23 |
| 23 using ::testing::InSequence; | 24 using ::testing::InSequence; |
| 24 using ::testing::StrictMock; | 25 using ::testing::StrictMock; |
| 25 | 26 |
| 26 class JsSyncEncryptionHandlerObserverTest : public testing::Test { | 27 class JsSyncEncryptionHandlerObserverTest : public testing::Test { |
| 27 protected: | 28 protected: |
| 28 JsSyncEncryptionHandlerObserverTest() { | 29 JsSyncEncryptionHandlerObserverTest() { |
| 29 js_sync_encryption_handler_observer_.SetJsEventHandler( | 30 js_sync_encryption_handler_observer_.SetJsEventHandler( |
| 30 mock_js_event_handler_.AsWeakHandle()); | 31 mock_js_event_handler_.AsWeakHandle()); |
| 31 } | 32 } |
| 32 | 33 |
| 33 private: | 34 private: |
| 34 // This must be destroyed after the member variables below in order | 35 // This must be destroyed after the member variables below in order |
| 35 // for WeakHandles to be destroyed properly. | 36 // for WeakHandles to be destroyed properly. |
| 36 base::MessageLoop message_loop_; | 37 base::test::ScopedTaskEnvironment scoped_task_environment_; |
| 37 | 38 |
| 38 protected: | 39 protected: |
| 39 StrictMock<MockJsEventHandler> mock_js_event_handler_; | 40 StrictMock<MockJsEventHandler> mock_js_event_handler_; |
| 40 JsSyncEncryptionHandlerObserver js_sync_encryption_handler_observer_; | 41 JsSyncEncryptionHandlerObserver js_sync_encryption_handler_observer_; |
| 41 | 42 |
| 42 void PumpLoop() { base::RunLoop().RunUntilIdle(); } | 43 void PumpLoop() { base::RunLoop().RunUntilIdle(); } |
| 43 }; | 44 }; |
| 44 | 45 |
| 45 TEST_F(JsSyncEncryptionHandlerObserverTest, NoArgNotifiations) { | 46 TEST_F(JsSyncEncryptionHandlerObserverTest, NoArgNotifiations) { |
| 46 InSequence dummy; | 47 InSequence dummy; |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 HandleJsEvent("onPassphraseTypeChanged", | 157 HandleJsEvent("onPassphraseTypeChanged", |
| 157 HasDetailsAsDictionary(passphrase_type_details))); | 158 HasDetailsAsDictionary(passphrase_type_details))); |
| 158 | 159 |
| 159 js_sync_encryption_handler_observer_.OnPassphraseTypeChanged( | 160 js_sync_encryption_handler_observer_.OnPassphraseTypeChanged( |
| 160 PassphraseType::IMPLICIT_PASSPHRASE, ProtoTimeToTime(10)); | 161 PassphraseType::IMPLICIT_PASSPHRASE, ProtoTimeToTime(10)); |
| 161 PumpLoop(); | 162 PumpLoop(); |
| 162 } | 163 } |
| 163 | 164 |
| 164 } // namespace | 165 } // namespace |
| 165 } // namespace syncer | 166 } // namespace syncer |
| OLD | NEW |