Merge lp://qastaging/~nick-dedekind/unity/lp1062107.preview-pre-caching into lp://qastaging/unity

Proposed by Nick Dedekind
Status: Work in progress
Proposed branch: lp://qastaging/~nick-dedekind/unity/lp1062107.preview-pre-caching
Merge into: lp://qastaging/unity
Diff against target: 1176 lines (+675/-75)
22 files modified
UnityCore/CMakeLists.txt (+2/-0)
UnityCore/HomeLens.cpp (+2/-2)
UnityCore/HomeLens.h (+1/-1)
UnityCore/Lens.cpp (+25/-25)
UnityCore/Lens.h (+3/-1)
UnityCore/PreviewPreCacher.cpp (+270/-0)
UnityCore/PreviewPreCacher.h (+94/-0)
dash/DashView.cpp (+8/-3)
dash/LensView.cpp (+15/-13)
dash/LensView.h (+7/-3)
dash/previews/ApplicationPreview.cpp (+3/-3)
dash/previews/GenericPreview.cpp (+2/-2)
dash/previews/MoviePreview.cpp (+2/-2)
dash/previews/MusicPreview.cpp (+2/-2)
dash/previews/PreviewContainer.cpp (+1/-1)
dash/previews/PreviewInfoHintWidget.cpp (+1/-1)
dash/previews/SocialPreview.cpp (+3/-3)
dash/previews/SocialPreviewComments.cpp (+1/-1)
dash/previews/SocialPreviewContent.cpp (+4/-4)
tests/CMakeLists.txt (+1/-0)
tests/test_lens.cpp (+4/-8)
tests/test_previews_precacher.cpp (+224/-0)
To merge this branch: bzr merge lp://qastaging/~nick-dedekind/unity/lp1062107.preview-pre-caching
Reviewer Review Type Date Requested Status
Brandon Schaefer (community) Needs Fixing
Review via email: mp+133446@code.qastaging.launchpad.net

Commit message

Added dash preview pre-caching. (LP: #1062107)

Description of the change

= Problem description =

https://bugs.launchpad.net/unity/+bug/1062107
Preview content should be speculatively cached

= The fix =

1. When the user opens a preview, results subsequent to the preview start pre-cacheing.

2. Once a user has previewed one content item underneath a category header, as long as the Dash remains open we continue to speculatively cache the preview content for the other items under the category header (even when the user returns to the results view). The pre-caching stops when a) the user closes the Dash b) the user previews the a result from underneath another category header. In this second case the Dash then starts speculatively pre-cacheing the content from underneath this new category header.

= Test coverage =

Unit tests for pre-caching queue execution.

To post a comment you must log in.
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

530 + virtual ~PreviewPreCacher();
551 + virtual void OnPreCacheComplete();

Could we make those pure virtual fucntions?

Or if not could we just do:
530 + virtual ~PreviewPreCacher() {}
551 + virtual void OnPreCacheComplete() {}

347 + if (index < 0 || index >=(int)GetResultCount())

Does this need to be casted to an int?

758 + int top_social_info_max_width = MAX(details_width - style.GetAppIconAreaWidth() - style.GetSpaceBetweenIconAndDetails(), 0);
772 + int max_width = MAX(0, geo_cr.width - 2*(geo_cr.width*0.1));
773 + int max_height = MAX(0, (geo_cr.height - TAIL_HEIGHT) - 2*((geo_cr.height - TAIL_HEIGHT)*0.1));
786 + title_->SetMaximumWidth(MAX(0, GetGeometry().width - geo.height - style.GetMusicDurationWidth() - layout_spacing*2));

Lets use std::max() here.

review: Needs Fixing
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

bschaefer@bschaefer:unity$ bzr merge lp:~nick-dedekind/unity/lp1062107.preview-pre-caching
+N UnityCore/PreviewPreCacher.cpp
+N UnityCore/PreviewPreCacher.h
+N tests/test_previews_precacher.cpp
 M UnityCore/CMakeLists.txt
 M UnityCore/HomeLens.cpp
 M UnityCore/HomeLens.h
 M UnityCore/Lens.cpp
 M UnityCore/Lens.h
 M dash/DashView.cpp
 M dash/LensView.cpp
 M dash/LensView.h
 M dash/previews/PreviewContainer.cpp
 M dash/previews/SocialPreview.cpp
 M dash/previews/SocialPreviewContent.cpp
 M dash/previews/Track.cpp
 M tests/CMakeLists.txt
 M tests/test_lens.cpp
Text conflict in dash/LensView.cpp
Text conflict in dash/previews/Track.cpp
Text conflict in tests/CMakeLists.txt
3 conflicts encountered.

review: Needs Fixing
Revision history for this message
Nick Dedekind (nick-dedekind) wrote :

> 530 + virtual ~PreviewPreCacher();
> 551 + virtual void OnPreCacheComplete();
>
> Could we make those pure virtual fucntions?
>
> Or if not could we just do:
> 530 + virtual ~PreviewPreCacher() {}
> 551 + virtual void OnPreCacheComplete() {}
>

Can't be pure virtual because we need to instantiate a PreviewPreCacher.
Don't see any benefit in making them inline.

>
> 347 + if (index < 0 || index >=(int)GetResultCount())
>
> Does this need to be casted to an int?
>

Yes. GetResultCount returns an unsigned int. Comes from the dee model.

>
> 758 + int top_social_info_max_width = MAX(details_width -
> style.GetAppIconAreaWidth() - style.GetSpaceBetweenIconAndDetails(), 0);
> 772 + int max_width = MAX(0, geo_cr.width - 2*(geo_cr.width*0.1));
> 773 + int max_height = MAX(0, (geo_cr.height - TAIL_HEIGHT) -
> 2*((geo_cr.height - TAIL_HEIGHT)*0.1));
> 786 + title_->SetMaximumWidth(MAX(0, GetGeometry().width - geo.height -
> style.GetMusicDurationWidth() - layout_spacing*2));
>
> Lets use std::max() here.

Will do.

2880. By Nick Dedekind

switched preview code to use std::max

2881. By Nick Dedekind

Merged with trunk

Revision history for this message
Nick Dedekind (nick-dedekind) wrote :

Use std::max for preview code.
Merged with trunk.

Revision history for this message
Andrea Azzarone (azzar1) wrote :

tests/test_previews_precacher.cpp

I don't like the way you're testing PreviewPreCacher because you're testing a mock of it (MockPreviewPreCacher).

Also PreviewPreCacher should inherit from sigc::trackable.

Revision history for this message
Nick Dedekind (nick-dedekind) wrote :

@andyrock: As stated in the description, the supplied test is only meant to check the preview pre-caching sequence (pretty much only the PreviewPreCacher::ContinuePreCaching function).

Getting a lens view into the test harness to test the pre-cacher interaction is somewhat controversial and not suited to unit testing at the moment (Lens Dee related code is "too tight" for testability).
I am hoping to get some refactoring into the lenses soon so they can be properly tested. Once this is done, we can revisit this.

Revision history for this message
Nick Dedekind (nick-dedekind) wrote :

Some previews (eg MusicPreview) are stateful inside libunity, therefore asking for subsiquent previews while viewing another will hose the state.
Until this is recitfied, this cannot be merged.

Unmerged revisions

2881. By Nick Dedekind

Merged with trunk

2880. By Nick Dedekind

switched preview code to use std::max

2879. By Nick Dedekind

Preview pre-caching tweaks.

2878. By Nick Dedekind

Removed debuggin code.

2877. By Nick Dedekind

Added precache files.

2876. By Nick Dedekind

Added speculative caching to previews.

2875. By Nick Dedekind

Check for width > 0 in preview layout management.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.