forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support code to test the cast system tray item.
This supporting code is used in https://codereview.chromium.org/1231593002/. BUG=497343 Review URL: https://codereview.chromium.org/1218653006 Cr-Commit-Position: refs/heads/master@{#340790}
- Loading branch information
jdufault
authored and
Commit bot
committed
Jul 28, 2015
1 parent
b441cdd
commit b90450d
Showing
7 changed files
with
159 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Copyright 2015 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "ash/test/tray_cast_test_api.h" | ||
|
||
#include "ash/system/tray/system_tray.h" | ||
#include "ui/views/view.h" | ||
|
||
namespace ash { | ||
|
||
TrayCastTestAPI::TrayCastTestAPI(TrayCast* tray_cast) : tray_cast_(tray_cast) {} | ||
|
||
TrayCastTestAPI::~TrayCastTestAPI() {} | ||
|
||
bool TrayCastTestAPI::IsTrayInitialized() const { | ||
return tray_cast_->default_ != nullptr; | ||
} | ||
|
||
bool TrayCastTestAPI::IsTrayVisible() const { | ||
return IsViewDrawn(TrayCast::TRAY_VIEW); | ||
} | ||
|
||
bool TrayCastTestAPI::IsTrayCastViewVisible() const { | ||
return IsViewDrawn(TrayCast::CAST_VIEW); | ||
} | ||
|
||
bool TrayCastTestAPI::IsTraySelectViewVisible() const { | ||
return IsViewDrawn(TrayCast::SELECT_VIEW); | ||
} | ||
|
||
void TrayCastTestAPI::StartCast(const std::string& receiver_id) { | ||
return tray_cast_->StartCastForTest(receiver_id); | ||
} | ||
|
||
void TrayCastTestAPI::StopCast() { | ||
return tray_cast_->StopCastForTest(); | ||
} | ||
|
||
void TrayCastTestAPI::OnCastingSessionStartedOrStopped(bool is_casting) { | ||
tray_cast_->OnCastingSessionStartedOrStopped(is_casting); | ||
} | ||
|
||
bool TrayCastTestAPI::IsViewDrawn(TrayCast::ChildViewId id) const { | ||
const views::View* view = tray_cast_->GetDefaultView()->GetViewByID(id); | ||
return view != nullptr && view->IsDrawn(); | ||
} | ||
|
||
} // namespace ash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Copyright 2015 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef ASH_TEST_TRAY_CAST_TEST_API_H_ | ||
#define ASH_TEST_TRAY_CAST_TEST_API_H_ | ||
|
||
#include <string> | ||
|
||
#include "ash/ash_export.h" | ||
#include "ash/system/cast/tray_cast.h" | ||
|
||
namespace ash { | ||
|
||
class TrayCastTestAPI { | ||
public: | ||
explicit TrayCastTestAPI(TrayCast* tray_cast); | ||
~TrayCastTestAPI(); | ||
|
||
bool IsTrayInitialized() const; | ||
bool IsTrayVisible() const; | ||
|
||
// IsTrayCastViewVisible returns true if the active casting view is | ||
// visible, ie, the TrayCast believes we are casting. | ||
// IsTraySelectViewVisible returns true when the view for selecting a | ||
// receiver is active, ie, the TrayCast believes we are not casting. | ||
bool IsTrayCastViewVisible() const; | ||
bool IsTraySelectViewVisible() const; | ||
|
||
// Start a new cast to the given receiver. | ||
void StartCast(const std::string& receiver_id); | ||
void StopCast(); | ||
|
||
// Exposed callback to update the casting state. The test code needs to call | ||
// this function manually, as there is no actual casting going on. In a real | ||
// environment, this method is invoked by the casting system in Chrome. | ||
void OnCastingSessionStartedOrStopped(bool is_casting); | ||
|
||
private: | ||
bool IsViewDrawn(TrayCast::ChildViewId id) const; | ||
|
||
// Not owned. | ||
TrayCast* tray_cast_; | ||
|
||
DISALLOW_COPY_AND_ASSIGN(TrayCastTestAPI); | ||
}; | ||
|
||
} // namespace ash | ||
|
||
#endif // ASH_TEST_TRAY_CAST_TEST_API_H_ |