Home | History | Annotate | Download | only in update_manager
      1 //
      2 // Copyright (C) 2014 The Android Open Source Project
      3 //
      4 // Licensed under the Apache License, Version 2.0 (the "License");
      5 // you may not use this file except in compliance with the License.
      6 // You may obtain a copy of the License at
      7 //
      8 //      http://www.apache.org/licenses/LICENSE-2.0
      9 //
     10 // Unless required by applicable law or agreed to in writing, software
     11 // distributed under the License is distributed on an "AS IS" BASIS,
     12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13 // See the License for the specific language governing permissions and
     14 // limitations under the License.
     15 //
     16 
     17 #ifndef UPDATE_ENGINE_UPDATE_MANAGER_FAKE_UPDATER_PROVIDER_H_
     18 #define UPDATE_ENGINE_UPDATE_MANAGER_FAKE_UPDATER_PROVIDER_H_
     19 
     20 #include <string>
     21 
     22 #include "update_engine/update_manager/fake_variable.h"
     23 #include "update_engine/update_manager/updater_provider.h"
     24 
     25 namespace chromeos_update_manager {
     26 
     27 // Fake implementation of the UpdaterProvider base class.
     28 class FakeUpdaterProvider : public UpdaterProvider {
     29  public:
     30   FakeUpdaterProvider() {}
     31 
     32   FakeVariable<base::Time>* var_updater_started_time() override {
     33     return &var_updater_started_time_;
     34   }
     35 
     36   FakeVariable<base::Time>* var_last_checked_time() override {
     37     return &var_last_checked_time_;
     38   }
     39 
     40   FakeVariable<base::Time>* var_update_completed_time() override {
     41     return &var_update_completed_time_;
     42   }
     43 
     44   FakeVariable<double>* var_progress() override {
     45     return &var_progress_;
     46   }
     47 
     48   FakeVariable<Stage>* var_stage() override {
     49     return &var_stage_;
     50   }
     51 
     52   FakeVariable<std::string>* var_new_version() override {
     53     return &var_new_version_;
     54   }
     55 
     56   FakeVariable<int64_t>* var_payload_size() override {
     57     return &var_payload_size_;
     58   }
     59 
     60   FakeVariable<std::string>* var_curr_channel() override {
     61     return &var_curr_channel_;
     62   }
     63 
     64   FakeVariable<std::string>* var_new_channel() override {
     65     return &var_new_channel_;
     66   }
     67 
     68   FakeVariable<bool>* var_p2p_enabled() override {
     69     return &var_p2p_enabled_;
     70   }
     71 
     72   FakeVariable<bool>* var_cellular_enabled() override {
     73     return &var_cellular_enabled_;
     74   }
     75 
     76   FakeVariable<unsigned int>* var_consecutive_failed_update_checks() override {
     77     return &var_consecutive_failed_update_checks_;
     78   }
     79 
     80   FakeVariable<unsigned int>* var_server_dictated_poll_interval() override {
     81     return &var_server_dictated_poll_interval_;
     82   }
     83 
     84   FakeVariable<UpdateRequestStatus>* var_forced_update_requested() override {
     85     return &var_forced_update_requested_;
     86   }
     87 
     88  private:
     89   FakeVariable<base::Time>
     90       var_updater_started_time_{  // NOLINT(whitespace/braces)
     91     "updater_started_time", kVariableModePoll};
     92   FakeVariable<base::Time> var_last_checked_time_{  // NOLINT(whitespace/braces)
     93     "last_checked_time", kVariableModePoll};
     94   FakeVariable<base::Time>
     95       var_update_completed_time_{  // NOLINT(whitespace/braces)
     96     "update_completed_time", kVariableModePoll};
     97   FakeVariable<double> var_progress_{  // NOLINT(whitespace/braces)
     98     "progress", kVariableModePoll};
     99   FakeVariable<Stage> var_stage_{  // NOLINT(whitespace/braces)
    100     "stage", kVariableModePoll};
    101   FakeVariable<std::string> var_new_version_{  // NOLINT(whitespace/braces)
    102     "new_version", kVariableModePoll};
    103   FakeVariable<int64_t> var_payload_size_{  // NOLINT(whitespace/braces)
    104     "payload_size", kVariableModePoll};
    105   FakeVariable<std::string> var_curr_channel_{  // NOLINT(whitespace/braces)
    106     "curr_channel", kVariableModePoll};
    107   FakeVariable<std::string> var_new_channel_{  // NOLINT(whitespace/braces)
    108     "new_channel", kVariableModePoll};
    109   FakeVariable<bool> var_p2p_enabled_{// NOLINT(whitespace/braces)
    110                                       "p2p_enabled",
    111                                       kVariableModeAsync};
    112   FakeVariable<bool> var_cellular_enabled_{// NOLINT(whitespace/braces)
    113                                            "cellular_enabled",
    114                                            kVariableModeAsync};
    115   FakeVariable<unsigned int>
    116       var_consecutive_failed_update_checks_{  // NOLINT(whitespace/braces)
    117     "consecutive_failed_update_checks", kVariableModePoll};
    118   FakeVariable<unsigned int>
    119       var_server_dictated_poll_interval_{  // NOLINT(whitespace/braces)
    120     "server_dictated_poll_interval", kVariableModePoll};
    121   FakeVariable<UpdateRequestStatus>
    122       var_forced_update_requested_{  // NOLINT(whitespace/braces)
    123     "forced_update_requested", kVariableModeAsync};
    124 
    125   DISALLOW_COPY_AND_ASSIGN(FakeUpdaterProvider);
    126 };
    127 
    128 }  // namespace chromeos_update_manager
    129 
    130 #endif  // UPDATE_ENGINE_UPDATE_MANAGER_FAKE_UPDATER_PROVIDER_H_
    131