Index: ash/system/cast/tray_cast.cc |
diff --git a/ash/system/cast/tray_cast.cc b/ash/system/cast/tray_cast.cc |
index 33ff8f191127472045eb2586a09c9960f7550c3f..e2bc892f0cfc3e9631d3cad0071628a9f90e5897 100644 |
--- a/ash/system/cast/tray_cast.cc |
+++ b/ash/system/cast/tray_cast.cc |
@@ -114,6 +114,8 @@ class CastCastView : public views::View, public views::ButtonListener { |
explicit CastCastView(CastConfigDelegate* cast_config_delegate); |
~CastCastView() override; |
+ void StopCasting(); |
+ |
// Updates the label for the stop view to include information about the |
// current device that is being casted. |
void UpdateLabel(); |
@@ -206,6 +208,12 @@ void CastCastView::Layout() { |
} |
} |
+void CastCastView::StopCasting() { |
+ cast_config_delegate_->StopCasting(); |
+ Shell::GetInstance()->metrics()->RecordUserMetricsAction( |
+ ash::UMA_STATUS_AREA_CAST_STOP_CAST); |
+} |
+ |
void CastCastView::UpdateLabel() { |
if (cast_config_delegate_ == nullptr || |
cast_config_delegate_->HasCastExtension() == false) |
@@ -245,9 +253,7 @@ void CastCastView::UpdateLabelCallback( |
void CastCastView::ButtonPressed(views::Button* sender, |
const ui::Event& event) { |
DCHECK(sender == stop_button_); |
- cast_config_delegate_->StopCasting(); |
- Shell::GetInstance()->metrics()->RecordUserMetricsAction( |
- ash::UMA_STATUS_AREA_CAST_STOP_CAST); |
+ StopCasting(); |
} |
// This view by itself does very little. It acts as a front-end for managing |
@@ -388,6 +394,8 @@ class CastDetailedView : public TrayDetailsView, public ViewClickListener { |
user::LoginStatus login); |
~CastDetailedView() override; |
+ void SimulateViewClickedForTest(std::string id); |
achuithb
2015/07/08 21:45:56
const std::string& receiver_id
jdufault
2015/07/09 23:11:28
Done.
|
+ |
private: |
void CreateItems(); |
@@ -430,6 +438,15 @@ CastDetailedView::CastDetailedView(SystemTrayItem* owner, |
CastDetailedView::~CastDetailedView() { |
} |
+void CastDetailedView::SimulateViewClickedForTest(std::string id) { |
+ for (auto& it : receiver_activity_map_) { |
+ if (it.second == id) { |
+ OnViewClicked(it.first); |
+ break; |
+ } |
+ } |
+} |
+ |
void CastDetailedView::CreateItems() { |
CreateScrollableList(); |
AppendSettingsEntries(); |
@@ -548,6 +565,23 @@ TrayCast::~TrayCast() { |
Shell::GetInstance()->RemoveShellObserver(this); |
} |
+bool TrayCast::IsTrayInitializedForTest() { |
+ return default_ != nullptr; |
+} |
+ |
+bool TrayCast::IsTrayVisibleForTest() { |
+ return default_ != nullptr && default_->IsDrawn(); |
+} |
+ |
+void TrayCast::StartCastForTest(std::string id) { |
+ if (detailed_ != nullptr) |
+ detailed_->SimulateViewClickedForTest(id); |
+} |
+ |
+void TrayCast::StopCastForTest() { |
+ default_->cast_view()->StopCasting(); |
+} |
+ |
views::View* TrayCast::CreateTrayView(user::LoginStatus status) { |
CHECK(tray_ == nullptr); |
tray_ = new tray::CastTrayView(this); |