[UITest] add share Image activity

RESOLVED FIXED

Status

RESOLVED FIXED
5 years ago
5 years ago

People

(Reporter: gasolin, Assigned: rishav_)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: [good first bug][mentor=gasolin][mentor-lang=zh][lang=js])

Attachments

(1 attachment, 2 obsolete attachments)

(Reporter)

Description

5 years ago
Expect:

extend test_apps/uitest by add 'share Image' activity in API tab


The activity could reference to http://robnyman.github.io/Firefox-OS-Boilerplate-App

var shareImage = document.querySelector("#share-image"),
        imgToShare = document.querySelector("#image-to-share");
    if (shareImage && imgToShare) {
        shareImage.onclick = function () {
            if(imgToShare.naturalWidth > 0) {
                // Create dummy canvas
                var blobCanvas = document.createElement("canvas");
                blobCanvas.width = imgToShare.width;
                blobCanvas.height = imgToShare.height;

                // Get context and draw image
                var blobCanvasContext = blobCanvas.getContext("2d");
                blobCanvasContext.drawImage(imgToShare, 0, 0);

                // Export to blob and share through a Web Activitiy
                blobCanvas.toBlob(function (blob) {
                    var sharingImage = new MozActivity({
                        name: "share",
                        data: {
                            type: "image/*",
                            number: 1,
                            blobs: [blob]
                        }
                    });
                });
            }
            else {
                alert("Image failed to load, can't be shared");
            }
        }
    }
(Reporter)

Updated

5 years ago
Whiteboard: [good first bug][mentor=gasolin][mentor-lang=zh][lang=js]
(Assignee)

Comment 1

5 years ago
Hi Fred,
Can I get assigned this bug? I am interested in this. It will be very helpful if you will provide more info about this bug :)
Thanks
(Reporter)

Comment 2

5 years ago
If you have real device it will be a plus to test activity.
Or you could try on tools/web developer/App Manager.


Open it, start a simulator, use 'Add packaged App' to load gaia/test_apps/uitest into simulator

Open `uitest` in simulator, switch to API/photo, click `Pick Photo` any to see the result.

You could add `Share Image` in uitest/index.html, uitest/test_html/API and uitest/js/API with above code.
Assignee: nobody → rishav006
(Assignee)

Comment 3

5 years ago
Hi Fred,
What you code provided above, is for  Firefox-Os-BoilerPlate App.
I can add the code (given above) in uitest/js/API. But what i have to add in uitest/test_html/API (For that i need to create a more page "shareimage.html" like others audio.html,contact.html, But what should be the content of it, because nothing like this is given in Firefox OS BoilerPlate App).
Please help.
Also what is your irc nickname (so that i can ask you there).

Thanks
Flags: needinfo?(gasolin)
(Reporter)

Comment 4

5 years ago
add a line `share blob image` before button is fine for me. 
Or you can even include an image ex 'style/images/canardpc.jpg' and put shared button under it.


my irc nickname is `gasolin`, now its holiday so I may not on irc sometime.
Flags: needinfo?(gasolin)
(Assignee)

Comment 5

5 years ago
Created attachment 8351015 [details] [review]
Add share Image Activity
Attachment #8351015 - Flags: review?(gasolin)
(Assignee)

Comment 6

5 years ago
Hi Fred
I Added   " Share Image " Activity .
Modification in test_apps/uitest/index.html
Addition of  
test_apps/uitest/tests_html/API/shareimage.html  
and 
test_apps/uitest/js/API/shareimage.js 

Please have a look and tell if there any more stuff need to add.

Thanks
(Reporter)

Comment 7

5 years ago
Hi kumar,

The overall looks perfectly, thanks for your contribution!

Please rebase your PR to not include other's commit.
(Assignee)

Comment 8

5 years ago
Hi fred
Can you explain "Please rebase your PR to not include other's commit".
How to do this.
I didn't get it.(First time i am doing bug fixing,so ... please help).

Thanks
(Reporter)

Comment 9

5 years ago
Sure. there are two commits in your Pull request, one is not related to this issue.
The root cause might be your previous commits is backout(make gaia test fail so the commit is reverted) from current gaia master.


The simple way to solve this issue is 
1. to save your changes to other place
2. create a new fresh branch
3. paste your changes there
4. create a new Pull request

The other way is (might be harder)

1. add remote git to your local gaia repository:

  $ git remote add upstream https://github.com/mozilla-b2g/gaia.git

2. update remote commits by command:

  $ remote update

3. rebase your current branch to newest commits

  $ git rebase upstream/master


I suggest you take the first approach if you not really familiar with git operation.
(Assignee)

Comment 10

5 years ago
Hi fred,
What to do with previous branch(i created) and pull request.
Thanks
(Assignee)

Comment 11

5 years ago
Hi Fred
Is this ok?
pull request 
https://github.com/mozilla-b2g/gaia/pull/14929
Thanks
(Assignee)

Comment 12

5 years ago
Created attachment 8351135 [details] [review]
Add share Image Activity
Attachment #8351135 - Flags: review?(gasolin)
(Reporter)

Updated

5 years ago
Attachment #8351015 - Flags: review?(gasolin)
(Reporter)

Comment 13

5 years ago
Comment on attachment 8351135 [details] [review]
Add share Image Activity

still see 'alive''s commit in your Pull request
Attachment #8351135 - Flags: review?(gasolin)
(Reporter)

Comment 14

5 years ago
Your current local git or forked repository is a bit outdate,

please create a new branch with following steps:

1. add remote git to your local gaia repository:

  $ git remote add upstream https://github.com/mozilla-b2g/gaia.git

2. update remote commits by command:

  $ remote update

3. create a new branch

$ git checkout -b issue-944288 upstream/master 

and do your modification here
(Reporter)

Comment 15

5 years ago
step 2 command is 

$ git remote update
(Assignee)

Comment 16

5 years ago
Hi Fred,
Are you online currently on irc. I need some help.
Thanks
(Assignee)

Comment 17

5 years ago
Created attachment 8351148 [details] [review]
Add share Image Activity
Attachment #8351015 - Attachment is obsolete: true
Attachment #8351135 - Attachment is obsolete: true
Attachment #8351148 - Flags: review?(gasolin)
(Reporter)

Comment 18

5 years ago
Comment on attachment 8351148 [details] [review]
Add share Image Activity

It works perfectly, thanks and congratulate your first contribution!
Attachment #8351148 - Flags: review?(gasolin) → review+
(Reporter)

Comment 19

5 years ago
merged to gaia-master https://github.com/mozilla-b2g/gaia/commit/1d1f3156d9625981ed9d4e5322831c2b038ea70b
Status: NEW → RESOLVED
Last Resolved: 5 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.