| 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/sessions/sync_session.h" | 5 #include "sync/sessions/sync_session.h" |
| 6 #include "sync/test/engine/test_id_factory.h" | 6 #include "sync/test/engine/test_id_factory.h" |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 | 8 |
| 9 namespace syncer { | 9 namespace syncer { |
| 10 namespace sessions { | 10 namespace sessions { |
| 11 | 11 |
| 12 class StatusControllerTest : public testing::Test { | 12 class StatusControllerTest : public testing::Test { |
| 13 public: | 13 public: |
| 14 virtual void SetUp() { | 14 virtual void SetUp() { |
| 15 routes_[BOOKMARKS] = GROUP_UI; | 15 routes_[BOOKMARKS] = GROUP_UI; |
| 16 } | 16 } |
| 17 protected: | 17 protected: |
| 18 ModelSafeRoutingInfo routes_; | 18 ModelSafeRoutingInfo routes_; |
| 19 }; | 19 }; |
| 20 | 20 |
| 21 // This test is useful, as simple as it sounds, due to the copy-paste prone | 21 // This test is useful, as simple as it sounds, due to the copy-paste prone |
| 22 // nature of status_controller.cc (we have had bugs in the past where a set_foo | 22 // nature of status_controller.cc (we have had bugs in the past where a set_foo |
| 23 // method was actually setting |bar_| instead!). | 23 // method was actually setting |bar_| instead!). |
| 24 TEST_F(StatusControllerTest, ReadYourWrites) { | 24 TEST_F(StatusControllerTest, ReadYourWrites) { |
| 25 StatusController status(routes_); | 25 StatusController status(routes_); |
| 26 status.set_num_server_changes_remaining(13); | 26 status.set_num_server_changes_remaining(13); |
| 27 EXPECT_EQ(13, status.num_server_changes_remaining()); | 27 EXPECT_EQ(13, status.num_server_changes_remaining()); |
| 28 | 28 |
| 29 EXPECT_FALSE(status.conflicts_resolved()); | |
| 30 status.update_conflicts_resolved(true); | |
| 31 EXPECT_TRUE(status.conflicts_resolved()); | |
| 32 | |
| 33 status.set_last_download_updates_result(SYNCER_OK); | 29 status.set_last_download_updates_result(SYNCER_OK); |
| 34 EXPECT_EQ(SYNCER_OK, | 30 EXPECT_EQ(SYNCER_OK, |
| 35 status.model_neutral_state().last_download_updates_result); | 31 status.model_neutral_state().last_download_updates_result); |
| 36 | 32 |
| 37 status.set_commit_result(SYNC_AUTH_ERROR); | 33 status.set_commit_result(SYNC_AUTH_ERROR); |
| 38 EXPECT_EQ(SYNC_AUTH_ERROR, status.model_neutral_state().commit_result); | 34 EXPECT_EQ(SYNC_AUTH_ERROR, status.model_neutral_state().commit_result); |
| 39 | 35 |
| 40 for (int i = 0; i < 14; i++) | 36 for (int i = 0; i < 14; i++) |
| 41 status.increment_num_successful_commits(); | 37 status.increment_num_successful_commits(); |
| 42 EXPECT_EQ(14, status.model_neutral_state().num_successful_commits); | 38 EXPECT_EQ(14, status.model_neutral_state().num_successful_commits); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 67 TEST_F(StatusControllerTest, Unrestricted) { | 63 TEST_F(StatusControllerTest, Unrestricted) { |
| 68 StatusController status(routes_); | 64 StatusController status(routes_); |
| 69 status.model_neutral_state(); | 65 status.model_neutral_state(); |
| 70 status.download_updates_succeeded(); | 66 status.download_updates_succeeded(); |
| 71 status.ServerSaysNothingMoreToDownload(); | 67 status.ServerSaysNothingMoreToDownload(); |
| 72 status.group_restriction(); | 68 status.group_restriction(); |
| 73 } | 69 } |
| 74 | 70 |
| 75 } // namespace sessions | 71 } // namespace sessions |
| 76 } // namespace syncer | 72 } // namespace syncer |
| OLD | NEW |